1 year ago

#386222

test-img

Collin Alpert

Mapping records with AutoMapper's ProjectTo() throws exception

Here is a gist for reproducing the bug: https://gist.github.com/CollinAlpert/075d341fc0e24bb8f4eb8053983d93df

I have am trying to map EF Core queries to records using AutoMapper's ProjectTo method. Mapping using the mapper.Map() method works fine, so my mapping doesn't seem to be the problem. However when calling ProjectTo, the following exception gets thrown.

Unhandled exception. AutoMapper.AutoMapperMappingException: Unable to create a map expression from Station.IsActive (System.Int32) to Boolean.IsActive (System.Boolean)

Mapping types:
Station -> StationDto
Test.Station -> Test.StationDto

Type Map configuration:
Station -> StationDto
Test.Station -> Test.StationDto

Destination Member:
IsActive

   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at Test.Program.Main() in /Users/collin/Programmieren/dotNET/Test/Test/Program.cs:line 24

c#

sqlite

.net-core

automapper

0 Answers

Your Answer

Accepted video resources