开发者

How to add entity object to adequate entity set with object context in EF?

开发者 https://www.devze.com 2022-12-26 14:00 出处:网络
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 kn

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消