Question

I am missing something very fundamental when working with SL4 RIA entities. I have a Domain Service with User entities. On the service context, I have a method:

EntityQuery<User> GetUsersQuery()

I perform a load like so:

context.Load(context.GetUsersQuery(), (loadOp)=> 
{
  // Things done when the load is completed
}, null);

When the Completed action executes, the loadOp.Entities collection is full of the User entities, but they are not attached to the context.Users entity set. It also appears that I can't attach them manually from the callback. What important step am I missing to get these tracked in the entity set?


Just to elaborate, in the completed handler, I tried:

foreach (var user in loadOp.Entities)
    context.Users.Attach(user);

And I get an exception that says an entity with that name is already attached. Yet, both context.Users and context.EntityContainer are empty.

Was it helpful?

Solution

Are you sure you are using the same instance of the context in all cases? What does context.EntityContainer.GetEntitySet<User>().Count say?

Does LoadOperation<User>.HasError return true? If so, what is the error?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top