I ended up hacking: C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.1\Frameworks\NHibernate\Templates\Shared\Shared\generalTemplateUtils.lpt:
At line 361:
internal static string ProduceTypeConverterTypeString(FieldMapping mapping)
{
if(mapping.TypeConverterToUse==null)
{
if (mapping.MappedFieldTypeAsString.Contains("datetime "))
return " type=\"datetime2\"";
return string.Empty;
}
return string.Format(" type=\"{0}, {1}\"", mapping.TypeConverterToUse.TypeFullName, mapping.TypeConverterToUse.AssemblyName);
}
I added this block:
if (mapping.MappedFieldTypeAsString.Contains("datetime "))
return " type=\"datetime2\"";
I better way might have been to add a type converter but it seems to me a bit of a waste since NHibernate supports directly datetime2.
I also noticed that the llblgen pro doesn't store the db type for each column in the project file so there is really no way to make the distinction between a datetime and datetime2 field. Maybe this was one more reason to use a custom converter.
Any thoughts guys?
Thank you
PS. In case you wonder why the space after datetime:
if (mapping.MappedFieldTypeAsString.Contains("datetime "))
return " type=\"datetime2\"";
The mapping object doesn't seem to have a MappedFieldType property so I had to use the MappedFieldTypeAsString look for datetime, but because there is a datetimeoffset type as well I had to add the space.