Silverlight app debugging when used WCF RIA and Entity Framework
I am working on an app where I am using WCF RIA services and entity framework.
On laod,i have written a method which gets a list of schedules from database(as fetched using RIA method LoadOperation<>).
I have put a breakpoint on the method,but when 开发者_开发知识库I debug it the list shows 0 count and when I bind the empty list to datagrid,the grid shows all records.
How's this possible.
I got stuck in between
Kindly help for the same!!!
Loading data via the DomainContext is an asynchronous operation. Binding to a grid, etc. works because LoadOperation.Entities is observable and will fill in eventually. However, if you're trying to access it in code, you will have to wait for the callback.
myContext.Load(myContext.GetMyQuery(), OnLoadCompleted, null);
private void OnLoadCompleted(LoadOperation<MyEntity> op)
{
if (op.HasError)
{
// Handle error
op.MarkErrorAsHandled();
}
else
{
IEnumerable<MyEntity> entities = op.Entities;
// now do stuff with entities
}
}
See this page for more information.
精彩评论