I've read several questions/articles about WCF serialization of Entity Framework generated objects, but all of the solutions I've found involve turning on eager loading, which is exactly the thing I've trying NOT to do.
I'm essentially getting the same error as mentioned here The ObjectContext instance has been disposed - Winforms Entity Framework , the difference being that I'm consuming my WCF service from a Silverlight application.
I have a table User_Notifications that has a foreign key to a table User_Info. (A single User_Info can point to many User_Notifications in case I'm not using the terminology correctly). I'm using Entity Framework 4, which has created a class for both of those. I have a WCF call that returns:
return DBEntity.User_Notifications.Where(w => w.UserGUID == UserGuid && w.IsDismissed == false).ToArray();
This gives me all the User_Notifications that I need, but I get an ObjectContext Instance has been disposed error on the client side, which looks like from an attempt to load the associated User_Info class. I don't want the User_Info data though, I want it to just stay null or whatever, I don't need it for displaying notifications.
So, how can I pass my Entity Object without needing to pass the Associated Object?
My boss says this is just another reason why 'we don't need foreign keys in the database' and I'd really like to not go down that path.
User_Notifications, I'm going to post an answer, so hold onto your hat.