c# marking class property as dirty

前端 未结 11 2338
盖世英雄少女心
盖世英雄少女心 2020-11-29 19:32

The following is a simple example of an enum which defines the state of an object and a class which shows the implementation of this enum.

public enum Status         


        
11条回答
  •  抹茶落季
    2020-11-29 19:55

    One option is to change it on write; another is to keep a copy of all the original values and compute the dirtiness when anyone asks for it. That has the added benefit that you can tell exactly which fields have changed (and in what way) which means you can issue minimal update statements and make merge conflict resolution slightly easier.

    You also get to put all the dirtiness-checking in one place, so it doesn't pollute the rest of your code.

    I'm not saying it's perfect, but it's an option worth considering.

提交回复
热议问题