Can you convince a DataContext to treat a column as always dirty?

后端 未结 5 723
花落未央
花落未央 2020-12-06 02:39

Is there a way to force LINQ-to-SQL to treat a column as dirty? Globally would suffice....

Basically, I\'ve got a problem with some audit code on a legacy system tha

5条回答
  •  一向
    一向 (楼主)
    2020-12-06 03:16

    If you want to go down the [dirty] reflection route, you could try something along the lines of:

    1) Override SubmitChanges
    2) Go through the change set
    3) Use reflection to get hold of the change tracker for each updated object (see What's the cleanest way to make a Linq object "dirty"? )
    4) Make the column dirty (there's a dirtyMemberCache field in the StandardTrackedObject class)

提交回复
热议问题