Hi there!
In my previous posts, we resolved some issues about new Date/Time type mappings in Npgsql v3, but there is one unresolved.
The problem is that we must manually change field mappings of field, with db type time without timezone From System.DateTime to System.TimeSpan every time refreshing the relational model from DB.
We have such table:
CREATE TABLE OperationTime
(
Id BIGINT NOT NULL DEFAULT new_id() PRIMARY KEY,
TimeFrom TIME ,
TimeTo TIME
);
And for Npgsql to work correctly, it need to be a TimeSpan.
So every time we refreshing project from DB in field mappings of TimeFrom & TimeTo fields LLBLGEN maps it as DateTime. So in runtime we catch errors about Npgsql can not cast field value to DateTime, because it real value has Object(TimeSpan) type.
Errors looks like this:
2015-10-27 00:27:30.7051 [ERROR] SD.LLBLGen.Pro.ORMSupportClasses.ORMValueTypeMismatchException: The value 22:00:00 is of type 'System.TimeSpan' while the field is of type 'System.Nullable`1[System.DateTime]'
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCore`1.ValidateValue(IFieldInfo fieldToValidate, Object& value, Int32 fieldIndex)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCore`1.SetValue(Int32 fieldIndex, Object value, Boolean performDesyncForFKFields, Boolean checkForRefetch)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCore`1.SetValue(Int32 fieldIndex, Object value, Boolean checkForRefetch)
at core.entity.EntityClasses.OperationTimeEntity.set_TimeTo(Nullable`1 value)
at core.operations.OperationTimeOperation.Create(Int64 operationModeId, Int32 day, String timeFrom, String timeTo, ITransactionContext context)
What must we do to resolve this? And what we must do to every time not to perform magic with manual editting field mappings?