IgnoreMap and Ignore Attributes are different #3946
-
Source/destination types/* we used automapper to map to the same type but ignore some fields, to remove duplicate mappings in efcore when an include happened, long story.... */
public class X
{
public string XT { get; set; }
}
public class Hase
{
public int Id { get; set; }
// 11.0 does not work 11.0: [Ignore]
// 10.1 does work: [IgnoreMap]
public X X { get; set; }
} Mapping configurationvar mapper = new Mapper(new MapperConfiguration(config =>
{
config.CreateMap<Hase, Hase>();// Works on both Versions: .ForMember(h => h.X, f => f.Ignore());
}));
Version: x.y.z10.1.1 Expected behaviorthe Actual behaviorcurrently the Steps to reproduceConsole.WriteLine(JsonSerializer.Serialize(x));
Console.WriteLine(JsonSerializer.Serialize(mapper.Map<Hase>(x))); well we can easily create a manual mapper configuration which does work, unfortunatly the annotations are a little bit different than before (but I see no reason why Ignore should not Ignore the field tough) |
Beta Was this translation helpful? Give feedback.
Answered by
lbargaoanu
Mar 25, 2022
Replies: 1 comment
-
https://docs.automapper.org/en/latest/11.0-Upgrade-Guide.html#maptoattribute-and-ignoremapattribute-were-removed |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
lbargaoanu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://docs.automapper.org/en/latest/11.0-Upgrade-Guide.html#maptoattribute-and-ignoremapattribute-were-removed
[Ignore]
only applies to attribute mapping.