Skip to content Skip to sidebar Skip to footer

How Do I Stop The DateTimeOffset Scale From Causing A ChangeConflictException In Linq To Sql?

The following code tries to create a new record and then modify it after it has been committed to the database. The last SubmitChanges() call throws a ChangeConflictException. Item

Solution 1:

As you're always using Universal Time, I can't see what advantage DateTimeOffset gives you over DateTime. You could use DateTime.UtcNow, which has the same precision as Sql Server's DateTime.

Alternatively, as you're using Sql Server 2008, you could store your field as a DateTime2 in the database: this has the additional accuracy you require.


Post a Comment for "How Do I Stop The DateTimeOffset Scale From Causing A ChangeConflictException In Linq To Sql?"