I was just wondering, I tried giving a POCO Object to my WF4 workflow from my MVC Application, which worked just fine until I tried persisting it. I was loading my Object in a Using and when I persisted the workflow, it told me that it can not be persisted because the context does not exist anymore. Can anyone tell me why it needs the Context to serialize an object?
Getting my object with includes like this:
public User GetUser(string userName)
{
return (from user in _entities.Users.Include("Values").Include("RoleRelations")
where user.Name == userName
select user).FirstOrDefault();
}
Without the context if you're not eager loading all relevant data for your includes when you try to serialize it will try to Lazy-load them from the context. If the context has already been destroyed the POCO object cannot be fully populated, and so cannot be cleanly serialized.