DateTime mapping CodeFirst

DateTime mapping CodeFirst

Postby JoeRuspante » Wed 12 Sep 2012 09:29

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.
JoeRuspante
 
Posts: 54
Joined: Mon 05 Jul 2010 23:08

Re: DateTime mapping CodeFirst

Postby Shalex » Thu 13 Sep 2012 14:18

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/system.componentmodel.dataannotations.columnattribute.typename(v=vs.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/index.php/entity-framework-code-first-support-for-oracle-mysql-postgresql-and-sqlite.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.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Re: DateTime mapping CodeFirst

Postby Shalex » Wed 03 Oct 2012 08:45

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.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Re: DateTime mapping CodeFirst

Postby JoeRuspante » Thu 04 Oct 2012 09:17

Thank you very much
JoeRuspante
 
Posts: 54
Joined: Mon 05 Jul 2010 23:08

Re: DateTime mapping CodeFirst

Postby Shalex » Thu 04 Oct 2012 16:18

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.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle