开发者

I can't get Results from a Query in code behind in Silverlight Business Applications

开发者 https://www.devze.com 2023-03-21 05:26 出处:网络
regarding your book \"Pro Business Applications with Silverlight 4\" there is something that makes me cumbersome. I\'m Talking about getting results fro开发者_如何学Cm a query in code behind. Suppossi

regarding your book "Pro Business Applications with Silverlight 4" there is something that makes me cumbersome. I'm Talking about getting results fro开发者_如何学Cm a query in code behind. Suppossing you are using WCF RIA Services, you are always getting Nothing as a result due to asynchronous mecanism between Server and Client. I've tried to use a BusyIndicator like this (VB), but it doesn't work:

dim ctx as new DomainService1
dim query= from p As Entity1 In Ctx.GetQueryEntity1Query select p 

If ctx.IsLoading = True Then
   BusyIndicator1.IsBusy = True
   Else
   BusyIndicator1.IsBusy = False
End If

How to stop the Program until the Server has completed the Load Operation?


You need to load the entities using the Load-Method of the DomainContext class. This method expects a query to invoke and that specifies what entities to load. The Load-Method returnes an instance of LoadOperation that you can use to check if the load of the entities has finshed and to access the loaded entities.

Try to update your code as following:

dim ctx as new DomainService1
dim query= ctx.GetQueryEntity1Query
dim loadOperation = ctx.Load(query)

loadOperation.Completed += LoadCompleted
BusyIndicator1.IsBusy = True

Private Sub LoadCompleted(sender as object, e as EventArgs)
   BusyIndicator1.IsBusy = False
end Sub
0

精彩评论

暂无评论...
验证码 换一张
取 消