Unable to update the offset of a DateTimeOffset
I'm using Linqpad 5 at the moment and was attempting to update a DateTimeOffset.
My aim is to update to update the offset and save the value back to the database.
Considering the following,
var original = entity.CreatedOn; //'09/01/2020 06:23:05 +00:00'
var updated = original.ToOffset(new TimeSpan(8,0,0)); //'09/01/2020 14:23:05 +08:00'
entity.CreatedOn = updated;
Because the Equals method in DateTimeOffset checks that original and updated are the same point in time(which they still are). No update sql is generated.
Is there any way to force an entity or property into a changed state, or alternatively override the default equality comparer used for DateTimeOffset?
Or are there any other recommendations for solving this?
Thanks in advance.
Comments
I'm not sure how to do this in Linqpad5.... but it works in Linqpad6! LP6 uses a fork of Linq2Sql.