I have models with datetime fields.
My code is working with models setting this reseting this fields to now.
But I don't want "setting" now, but "saving" now: i.e. if I set field1 = now [0:00:00]
, then, 10s. later field2 = now [0:00:10]
and then, 10s. later, I execute SaveChanges()
I'd like to have both field set to 0:00:20 (saving time).
Edit: code example:
var context = new SomeEntities();
SomeModel model = context.GetSomeModel(...);
// SomeModel has two DateTime fields: dt1 and dt2
model.dt1 = SavingDateTimeNow(); // .... 13:42:00
// some code, i.e. Sleep(TimeSpan.FromSeconds(10));
model.dt2 = SavingDateTimeNow(); // .... 13:42:10
// again 10s. code
context.SaveChanges(); // .... 13:42:20
Edit2: More complex example:
var context = new SomeEntities();
SomeModel model = context.GetSomeModel(...);
// SomeModel has two DateTime fields: dt1 and dt2
if(someComplexCondition)model.dt1 = SavingDateTimeNow(); // .... 13:42:00
// some code from which I would know if someOtherComplexCondition is true
if(someOtherComplexCondition)model.dt2 = SavingDateTimeNow(); // .... 13:42:10
// again 10s. code
// much more code here
context.SaveChanges(); // .... 13:42:20
I want both (dt1 and dt2) to be set to ... 13:42:20, not 13:42:00 and 13:42:10
Edit3: Simplest example: I would like it to work just like django's fields with auto_now=True
.