http://blogs.msdn.com/b/smccraw/archive/2009/07/15/a-net-ria-services-data-load-batch-manager.aspx
I used a converter and it worked just fine but the instantiation of the class is looking for an Action(of DomainContextLoadBatch), but the subroutine, Private Sub DataLoadComplete(batch As DomainContextLoadBatch) is not an Action(of DomainContextLoadBatch). What does VB.Net need to make the DataLoadComplete routine work as an Action(of DomainContextLoadBatch) that fires only when all Entities have been loaded into the context. Works fine just the way it looks in C#. Hope that explains it, but I don't know enough about VB.NET to give a better explanation.
private DomainContext1 domainContext = new DomainContext1();
public MainPage()
{
InitializeComponent();
// here
DomainContextLoadBatch batch = new DomainContextLoadBatch(DataLoadComplete);
batch.Add(domainContext.Load(domainContext.GetUsersQuery()));
batch.Add(domainContext.Load(domainConte开发者_如何学Goxt.GetUserRolesQuery()));
batch.Add(domainContext.Load(domainContext.GetDisciplinesQuery()));
}
// and here
private void DataLoadComplete(DomainContextLoadBatch batch)
{
if (batch.FailedOperationCount > 0)
{
// Do Error handling
}
else
{
// Fill out the UI with the data
}
}
There are online-tools for converting C# code to VB.NET and vice-versa. One example is telerik's code converter.
精彩评论