What is the best way to compare two entity framework entities?

前端 未结 1 1483
庸人自扰
庸人自扰 2020-12-03 19:18

I want to know the most efficient way of comparing two entities of the same type.

One entity is created from an xml file by hand ( ie new instance and manually set p

相关标签:
1条回答
  • 2020-12-03 19:21

    Override the Equals method of your object and write an implementation that compares the properties that make it equal.

        public override bool Equals(object obj)
        {
            return MyProperty == ((MyObject)obj).MyProperty
        }
    
    0 讨论(0)
提交回复
热议问题