Transactions for C# objects?

前端 未结 8 802
青春惊慌失措
青春惊慌失措 2020-12-01 09:26

Just curious, is there any support for transactions on plain C# objects? Like

using (var transaction = new ObjectTransaction(obj))
{
  try
  {
    obj.Prop1          


        
8条回答
  •  一整个雨季
    2020-12-01 10:19

    You can make a copy of the object prior to executing methods and setting properties. Then, if you don't like the result, you can just "roll back" to the copy. Assuming, of course, that you have no side-effects to contend with.

提交回复
热议问题