Dapper Extensions is a small library that complements Dapper by adding basic CRUD operations (Get, Insert, Update, Delete) for your POCOs. For more advanced querying scenarios, Dapper Extensions provides a predicate system. The goal of this library is to keep your POCOs pure by not requiring any attributes or base class inheritance.
1.79k
stars
586
forks
source link
error mapping datetime (DB) to DateTimeOffset (entity) #291
Dapperextensions: error mapping datetime (DB) to DateTimeOffset (entity); However, dappercontrib mapping is normal.
System.Exception: Invalid cast from 'System.DateTime' to 'System.DateTimeOffset'.: An error occurred while mapping the value '2021/12/17 3:07:00' of type System.DateTime to the member name 'Birthday' of type System.DateTimeOffset on the MultiTenantDemo.Entity.User class.
---> System.InvalidCastException: Invalid cast from 'System.DateTime' to 'System.DateTimeOffset'.
at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
at System.DateTime.System.IConvertible.ToType(Type type, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType)
at Slapper.AutoMapper.Configuration.ValueTypeConverter.Convert(Object value, Type type)
at Slapper.AutoMapper.InternalHelpers.ConvertValuesTypeToMembersType(Object value, String memberName, Type memberType, Type classType)
--- End of inner exception stack trace ---
at Slapper.AutoMapper.InternalHelpers.ConvertValuesTypeToMembersType(Object value, String memberName, Type memberType, Type classType)
at Slapper.AutoMapper.InternalHelpers.SetMemberValue(Object member, Object obj, Object value)
at Slapper.AutoMapper.InternalHelpers.Map(IDictionary2 dictionary, Object instance, Object parentInstance) at Slapper.AutoMapper.Map(Type type, IEnumerable1 listOfProperties, Boolean keepCache)
at Slapper.AutoMapper.Map[T](IEnumerable1 listOfProperties, Boolean keepCache) at DapperExtensions.DapperImplementor.MappColumns[T](IEnumerable1 values)
at DapperExtensions.DapperImplementor.GetListAutoMap[T](IDbConnection connection, IList1 colsToSelect, IClassMapper classMap, IPredicate predicate, IList1 sort, IDbTransaction transaction, Nullable1 commandTimeout, Boolean buffered, IList1 includedProperties)
at DapperExtensions.DapperImplementor.InternalGetListAutoMap[T](IDbConnection connection, Object predicate, IList1 sort, IDbTransaction transaction, Nullable1 commandTimeout, Boolean buffered, IList1 colsToSelect, IList1 includedProperties)
at DapperExtensions.DapperAsyncImplementor.InternalGetListAutoMapAsync[T](IDbConnection connection, Object predicate, IList1 sort, IDbTransaction transaction, Nullable1 commandTimeout, Boolean buffered, IList1 colsToSelect, IList1 includedProperties)
at DapperExtensions.DapperAsyncImplementor.GetListAsync[T](IDbConnection connection, Object predicate, IList1 sort, IDbTransaction transaction, Nullable1 commandTimeout, Boolean buffered, IList1 colsToSelect, IList1 includedProperties)
at DapperExtensions.DapperAsyncExtensions.GetListAsync[T](IDbConnection connection, Object predicate, IList1 sort, IDbTransaction transaction, Nullable1 commandTimeout, Boolean buffered)
Dapperextensions: error mapping datetime (DB) to DateTimeOffset (entity); However, dappercontrib mapping is normal.
System.Exception: Invalid cast from 'System.DateTime' to 'System.DateTimeOffset'.: An error occurred while mapping the value '2021/12/17 3:07:00' of type System.DateTime to the member name 'Birthday' of type System.DateTimeOffset on the MultiTenantDemo.Entity.User class. ---> System.InvalidCastException: Invalid cast from 'System.DateTime' to 'System.DateTimeOffset'. at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) at System.DateTime.System.IConvertible.ToType(Type type, IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType) at Slapper.AutoMapper.Configuration.ValueTypeConverter.Convert(Object value, Type type) at Slapper.AutoMapper.InternalHelpers.ConvertValuesTypeToMembersType(Object value, String memberName, Type memberType, Type classType) --- End of inner exception stack trace --- at Slapper.AutoMapper.InternalHelpers.ConvertValuesTypeToMembersType(Object value, String memberName, Type memberType, Type classType) at Slapper.AutoMapper.InternalHelpers.SetMemberValue(Object member, Object obj, Object value) at Slapper.AutoMapper.InternalHelpers.Map(IDictionary
2 dictionary, Object instance, Object parentInstance) at Slapper.AutoMapper.Map(Type type, IEnumerable
1 listOfProperties, Boolean keepCache) at Slapper.AutoMapper.Map[T](IEnumerable1 listOfProperties, Boolean keepCache) at DapperExtensions.DapperImplementor.MappColumns[T](IEnumerable
1 values) at DapperExtensions.DapperImplementor.GetListAutoMap[T](IDbConnection connection, IList1 colsToSelect, IClassMapper classMap, IPredicate predicate, IList
1 sort, IDbTransaction transaction, Nullable1 commandTimeout, Boolean buffered, IList
1 includedProperties) at DapperExtensions.DapperImplementor.InternalGetListAutoMap[T](IDbConnection connection, Object predicate, IList1 sort, IDbTransaction transaction, Nullable
1 commandTimeout, Boolean buffered, IList1 colsToSelect, IList
1 includedProperties) at DapperExtensions.DapperAsyncImplementor.InternalGetListAutoMapAsync[T](IDbConnection connection, Object predicate, IList1 sort, IDbTransaction transaction, Nullable
1 commandTimeout, Boolean buffered, IList1 colsToSelect, IList
1 includedProperties) at DapperExtensions.DapperAsyncImplementor.GetListAsync[T](IDbConnection connection, Object predicate, IList1 sort, IDbTransaction transaction, Nullable
1 commandTimeout, Boolean buffered, IList1 colsToSelect, IList
1 includedProperties) at DapperExtensions.DapperAsyncExtensions.GetListAsync[T](IDbConnection connection, Object predicate, IList1 sort, IDbTransaction transaction, Nullable
1 commandTimeout, Boolean buffered)Where is the custom field mapping function