Open RIA Services User Support MVVM and LoadResult Types  Viewed 18322 time(s), 2 post(s)., 2/17/2015 1:32:09 AM - by Alyce

Alyce
Alyce 2/17/2015 1:32:10 AM

I've been using using Open Ria for a a while now, and getting along quite nicely. I have a data service that abstracts the Ria stuff away from the viewmodels, i.e. each viewmodel has IDataService injected into it, IDataService has methods like LoadRequest(int id) etc. I had been using Kyle McClellan's service result types (e.g. ServiceLoadResult) to pass back to the viewmodel, so the viewmodel did not have any reference to the OpenRia namespaces or types.

I'm now looking at using LoadAsync / SubmitChangesAsync. If I were calling the domain service method directly in the viewmodel, I'd do something like the following:

try
{
    var result = await ctx.LoadAsync(query);
}
catch (DomainOperationException ex)
{
    // Handle exception
}
Is there any guidance on pulling this into a data service so that the viewmodels do not need any reference to the OpenRiaServices.DomainServices.Client namespace?

This content has not been rated yet. 
43 Reputation 3 Total posts
1
ColinBlair
ColinBlair 2/20/2015 10:44:45 PM

I haven't done much with await in my Silverlight applications, mostly that is because I tend to write my applications in a very observable fashion. Meaning the IDataService returns an ObservableCollection that the view gets bound to. When the data gets loaded the view just populates automatically.

I have been using await extensively in the MVC applications I have been building, and my suggestion is that when using async/await the design of a Silverlight IDataService shouldn't be any different then how you would write the same thing using async in an MVC or Windows Store application. The only real fundamental difference is that, much like Kyle's original example, you would need to use QueryBuilder to write the query.

I hope someone else who has been using async more in Silverlight with Open RIA Services can give you additional suggestions.

This content has not been rated yet. 
1539 Reputation 130 Total posts
2