How to add entity object to adequate entity set with object context in EF?
I have a problem when I add an开发者_StackOverflow社区 entity object with ObjectContext.AddObject method because I can't retrieve that object with LINQ querying my ObjectContext.Person entities. I know that this new added object is stored somewhere, because it is used to update database after SaveChanges method. That's bothers me because I want to update my datagrid DataContext without saving changes unless I really want to do it. It doesn't help if I add the same object to DataContext list myself directly. Also, when I call DeleteObject method it just marks object for deleting but I have to find it an remove it from DataGrid and retrieve if I cancel changes.
If you add an object to your ObjectContext
and want to retrieve it without querying the database, you can use ObjectContext.GetObjectByKey.
Your second question is unclear to me.
精彩评论