Hi, the environment is the next:

  1. SQLServer (connectionUrl="sqlserver://MYSERVER/DO40-Tests")
  2. Session with a DisconnectedState.
  3. Entity with a DateTime field, datetime (not nullable)

It creates a new entity, the data are saved and retrieved by a query. It throws the following error: {"Version of entity with key 'MyEntity, (1)' differs from the expected one."}

MyEntity myentity = new MyEntity();` // datetime = 01/01/0001 (DateTime default in DO)

sessio.SaveChanges();

var t1 = sessio.Query.All<myentity>().First();` // {"Version of entity with key 'MyEntity, (1)' differs from the expected one."}
(datetime in the SQLServer is 01/01/1753, DateTime default in SQLServer)

Perhaps everything is correct, but is this the desired behavior?

Thanks,

PD Obviously, when DateTime is nullabe all is OK.

asked Mar 22 '11 at 05:04

Petar's gravatar image

Petar
5123

edited Mar 22 '11 at 06:20

Hello Petar,

Are you using SQL Server 2005?

(Mar 22 '11 at 07:39) Dmitri Maximov Dmitri%20Maximov's gravatar image

Yes, SQL Server 2005 (9.00.4053.00 SP3)

(Mar 22 '11 at 08:59) Petar Petar's gravatar image

One Answer:

The situation is that .NET DateTime type has wider range of values than MS SQL Server 2005 can provide, so 01/01/1753 is the minimal DateTime value it can store. Therefore, DataObjects.Net stores values less than 01/01/1753 value as 'minimal available value for the current database server'.

In MS SQL Server 2008 datetime2 datatype was introduced, it can store values from 01/01/0001. Consider migration to 2008 version.

answered Mar 22 '11 at 09:29

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211

edited Mar 22 '11 at 10:21

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA