DateTime to Date/Time

DateTime to Date/Time

Postby rogerio.bassete » Fri 23 Mar 2012 11:32

Hi,

I like maping .net DateTime to Date and DateTime to Time.

Is possible in Code First?
rogerio.bassete
 
Posts: 15
Joined: Sat 05 Aug 2006 20:55
Location: Brazil

Postby Shalex » Mon 26 Mar 2012 16:41

rogerio.bassete wrote:DateTime to Time

It is better to map TimeSpan to Time.

rogerio.bassete wrote:DateTime to Date

As we understood, you want to specify the server data type for the DateTime column. This can be done with ColumnAttribute (the TypeName property: http://msdn.microsoft.com/en-us/library ... e(v=vs.103).aspx ) or, in case of fluent mapping, with the .HasColumnType(string columnType) method of property configuration (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).

If you already have a database schema and you want just to map classes to it, the easier way to proceed is to create a Code-First model basing on the existing database with http://www.devart.com/blogs/dotconnect/index.php/entity-developer-ef-code-first-dbcontext-template.html.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL