Page 1 of 1

DateTime mapping CodeFirst

Posted: Wed 12 Sep 2012 09:29
by JoeRuspante
Hi everybody.

I have a problem with DateTime properties (.NET DateTime).
Using dotConnect for Oracle, it maps DateTime property on Oracle TIMESTAMP data type.

My problem is that I have another application that doesn't work with TIMESTAMP Oracle data type. It needs "DATE" type.

I tried to change the data type on the DB (manually), and I see that both applications will work (in our application, the user can insert at max minutes, so I don't lost any information).

So I'd like to know if there is any kind of setting that let me inform dotConnect to map DateTime property on Oracle DATE type instead of TIMESTAMP.
I don't want to do it for each property (like data attribute or special configuration for every property in the "OnModelCreating" event).

Thank you in advance.

Re: DateTime mapping CodeFirst

Posted: Thu 13 Sep 2012 14:18
by Shalex
JoeRuspante wrote:So I'd like to know if there is any kind of setting that let me inform dotConnect to map DateTime property on Oracle DATE type instead of TIMESTAMP.
There are 3 ways to fix the issue currently (for each property separately):
1. specify explicitly the server unicode data type (DATE) for your columns with ColumnAttribute (the TypeName property: http://msdn.microsoft.com/en-us/library ... .103).aspx )
2. fluent mapping:
2.1. specify explicitly the server unicode data type with the .HasColumnType(string columnType) method of property configuration
2.2. specify the zero precision via .HasPrecision(byte value)
An example of application with fluent mapping and detailed description of Code-First peculiarities is available at http://www.devart.com/blogs/dotconnect/ ... qlite.html
JoeRuspante wrote:I don't want to do it for each property (like data attribute or special configuration for every property in the "OnModelCreating" event).
We will investigate the possibility of implementing the corresponding configuration option.

Re: DateTime mapping CodeFirst

Posted: Wed 03 Oct 2012 08:45
by Shalex
The config.CodeFirstOptions.UseDateTimeAsDate option (default value is False) is added to treat DateTime properties without an explicitly specified server data type as DATE. We will post here when the corresponding build of dotConnect for Oracle is available for download.

Re: DateTime mapping CodeFirst

Posted: Thu 04 Oct 2012 09:17
by JoeRuspante
Thank you very much

Re: DateTime mapping CodeFirst

Posted: Thu 04 Oct 2012 16:18
by Shalex
New build of dotConnect for Oracle 7.2.96 is available for download!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=1&t=25020.