DateTime2 type as default for DateTime fields

Posts   
 
    
cerberis
User
Posts: 93
Joined: 20-May-2011
# Posted on: 17-Dec-2014 10:44:58   

Hello,

we are using latest LLBLGen Pro 4.2. in our database we use DateTime2(7) as data type in database (with modification in templates). However - we would like to have ability to specify default data type to DateTime2 to all DateTime fields in database mappings when creating new fields and which currently is datetime. Is it possible somehow?

regards Mantas

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 17-Dec-2014 17:23:58   

This is a hard-coded default in the driver at the moment. The driver provides 'priorities' for given types, see e.g. the SQL Server driver sourcecode, the DBDriver class, the method FillDBTypeSortOrderList. It provides per type a list of priorities. It also provides a list of filter lambdas so a .NET type with certain characteristics will result in a given type, e.g. DateTime. This is done in: FillNETToDBTypeConversionsList. So the .NET type 'DateTime' results in 4 different types. It then looks up what type has the highest priority (0), which is DateTime. DateTime2 is 4th.

At the moment the only way to customize is to alter the sql server driver. We didn't provide a UI for this as configuring is in most cases not needed and one can alter the field on a field by field basis if one wants to choose something else than the default.

However your situation shows that the lack of options to alter this sort list makes it hard to avoid the default when you want to do that for every field. For the current version we can't add it, but we'll look into adding a UI for this in the next version, to make sure users can define these lists to meet their requirements.

Frans Bouma | Lead developer LLBLGen Pro
cerberis
User
Posts: 93
Joined: 20-May-2011
# Posted on: 17-Dec-2014 20:17:53   

Thank you for the answer. For a workaround, is it possible to change data type when creating sql parameters? Maybe somewhere in adapter or query creator?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 18-Dec-2014 04:06:43   

No, unless you want to edit the generated code. Something like Find and Replace All, but would be a tedious job. Better to modify the SQL Server driver sourcecode.

cerberis
User
Posts: 93
Joined: 20-May-2011
# Posted on: 18-Dec-2014 07:56:02   

Walaa wrote:

No, unless you want to edit the generated code. Something like Find and Replace All, but would be a tedious job. Better to modify the SQL Server driver sourcecode.

Or modify PersistenceInfoProvider template simple_smile Thank you for answers. I will change template for now and will wait for improved designer simple_smile