如何查看一个EntitySet的和未提交的更改?EntitySet

2023-09-04 03:08:57 作者:未亡 Sakitam゜

我使用EF4和调试时,我希望看到什么样的变化即将作出的数据库。例如,如果我添加了一堆新的实体,如联系人,我希望看到将要当.SaveChanges添加联系人列表()执行。同样,如果会发生缺失,这将是很好看什么都会被删除。

I'm using EF4 and when debugging, I want to see what changes are about to be made to the database. For example, if I add a bunch of new entities, like contacts, I want to see the list of contacts that will be added when .SaveChanges() executes. Likewise, if deletions will occur, it would be nice to see what will be deleted.

有一个可视化工具或类似工具在VS2010这样做吗?

Is there a visualizer or similar tool in VS2010 that does this?

谢谢!

推荐答案

这直接是不可见的。最好的地方是检查 ObjectStateManager 持有状态条目每个实体和独立相关。每个 ObjectStateEntry 重presenting实体实体属性填补。

That is not visible directly. The best place is check ObjectStateManager which holds state entries for each entity and independent association. Each ObjectStateEntry representing entity has Entity property filled.

编辑:

如果您要访问这些数据,code,前者说明是非常有用的。如果你只是想看看它在调试器中添加 context.ObjectStateManager 来监视窗口并导航到非公共成员。您将看到字段:

The former description is useful if you want to access these data in code. If you just want to see it in debugger add context.ObjectStateManager to the watch window and navigate to Non-Public members. You will see fields like:

_addedEntityStore _deletedEntityStore _modifiedEntityStore _addedEntityStore _deletedEntityStore _modifiedEntityStore