Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error mapping datetime (DB) to DateTimeOffset (entity) #291

Open
xtxk110 opened this issue Dec 23, 2021 · 1 comment
Open

error mapping datetime (DB) to DateTimeOffset (entity) #291

xtxk110 opened this issue Dec 23, 2021 · 1 comment
Assignees
Labels
under investigation Issue is being analyzed

Comments

@xtxk110
Copy link

xtxk110 commented Dec 23, 2021

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

@valfrid-ly valfrid-ly self-assigned this Feb 17, 2022
@valfrid-ly valfrid-ly added the under investigation Issue is being analyzed label Feb 17, 2022
@valfrid-ly
Copy link
Collaborator

Please send your POCO and Mapper to check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
under investigation Issue is being analyzed
Projects
None yet
Development

No branches or pull requests

2 participants