等效的Entity Framework 4.0 GetChanges() [英] Entity Framework 4.0 GetChanges() equivalent

查看:63
本文介绍了等效的Entity Framework 4.0 GetChanges()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在LINQ to SQL中,您可以重写SubmitChanges并使用this.GetChangeSet()方法获取所有插入,更新和删除操作,以便您可以在最后一刻进行更改,然后再将其提交给数据库。

In LINQ to SQL, you can override SubmitChanges and use the method this.GetChangeSet() to get all the inserts, updates and deletes so that you can make last minute changes before it is committed to the database.

可以在EF 4.0中完成吗?我看到有一个SaveChanges的替代项,但我需要知道GetChangeSet()的等效项。

Can this be done in EF 4.0? I see there is a override for SaveChanges but I need to know the equivalent for GetChangeSet()

推荐答案

找到了它。

ObjectContext.ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Added);

ObjectContext.ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Added); for inserts.

这篇关于等效的Entity Framework 4.0 GetChanges()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆