Entity Framework: Is there a method to compare for equal values of EntityObject?

╄→гoц情女王★ 提交于 2019-12-10 16:41:52

问题


Is there a simple way to compare two EntityObjects for value-equality. I simply want to check if all the database-values are the same, so I don't care if the EntityKey is different.

Is this possible built-in? Or should I just write my own method.

I guess Equals() doesn't work as I want it here?


回答1:


Equals() checks for referential equality, so it wouldn't help you there.

Take a look at this question: What is the best way to compare two entity framework entities?

UPDATE 2014:
A more complete answer, in line with the current state of EF, would be that you could override the Equality operator in a code-first model to provide a check for value-equality.



来源:https://stackoverflow.com/questions/1785378/entity-framework-is-there-a-method-to-compare-for-equal-values-of-entityobject

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!