Thursday, May 31, 2012

Make dOOdads understand SQL Datatype Date


For you that are using the  dOOdads .NET architecture and are generating source based on tables that use the datatypes Date or Time and are getting Unknown in your code. Here is a simple solution to make MyGeneration create code that supports SQL data types Date and Time:

Locate your DbTargets.xml and add

<Type From="date" To="SqlDbType.Date" />
<Type From="time" To="SqlDbType.Time" />
 
Locate your Languages.xml and add

<Type From="date" To="DateTime" />
<Type From="time" To="TimeSpan" />
 
The dOOdads allready known the datatype TimeSpan so the rest is handlesd by the framework.
To add a Date in code use DateTime.TimeOfDay to get the TimeSpan