tmsmith / Dapper-Extensions

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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error mapping datetime (DB) to DateTimeOffset (entity)

xtxk110 opened this issue · comments

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)

Where is the custom field mapping function

Please send your POCO and Mapper to check.