Is there a better way to implment Equals for object with lots of fields?

后端 未结 4 2068
醉梦人生
醉梦人生 2021-01-15 09:15

see also Hows to quick check if data transfer two objects have equal properties in C#?

I have lot of Data Transfer Objects (DTO) tha

4条回答
  •  攒了一身酷
    2021-01-15 09:40

    You can have a concept of an object hash - whenever an object changes, you pay the price of updating the hash (where the hash is literally a hash of all concatenated properties). Then, if you have a bunch of objects that rarely change, it's really cheap to compare them. The price, of course, is then paid at object editing time.

提交回复
热议问题