Reputation: 950
i am creating silverlight application and implementing MVVM pattern. in my view model i want to get data from RIA service domain class. through following code
LoadOperation<DimensionDTO> loadOp = this.parametersDomainContext.Load(this.parametersDomainContext.GetDimensionDTOQuery());
List<DimensionDTO> Dimensions = LoadOperation.Entities as List<DimensionDTO> ;
though RIA service is returning data but in second line debugger shows entity count = 0
according to me this is because of asynchronous calling of RIA service. before return of data from ria service second line is executed. how can i make these two line synchronous. i mean second line should be executed when load operation is finished.
Upvotes: 0
Views: 853
Reputation: 752
in your View Model
[Query]
public IQueryable<DimensionDTO> GetDimensionDTOs()
{
return this.ObjectContext.DimensionDTOs;
}
in your Silverlight Code
DomainService1 DS = new DomainService1();
LoadOperation<DimensionDTO> loadOp = DS.Load(DS.GetDimensionDTOsQuery());
loadOp.Entities ; // for Assign to IEnumerable<DimensionDTO>
or
loadOp.Completed += new EventHandler((s,e)=>{
for(DimensionDTO item in loadOp.Entities )
{
// add entity to your list for List<DimensionDTO>
}
});
Upvotes: 2