Profile-level AllowNullCollections does not work for collections of mapped objects #3675
Answered
by
lbargaoanu
JustASquid
asked this question in
Q&A
-
Repro class TestProfile : Profile
{
public TestProfile()
{
AllowNullCollections = true;
CreateMap<A, B>();
}
}
class A
{
public string MyString { get; set; } = "";
}
class B
{
public string MyString { get; set; } = "";
}
static async Task Main(string[] args)
{
var mapper = new Mapper(new MapperConfiguration(cfg =>
{
cfg.AddProfile<TestProfile>();
}));
IList<A>? a = null;
var b = mapper.Map<IList<B>>(a);
// b is an empty list. I would expect b to be null.
Console.WriteLine(b);
} Version: 10.1.1Expected behavior
Actual behavior
|
Beta Was this translation helpful? Give feedback.
Answered by
lbargaoanu
Jun 22, 2021
Replies: 1 comment
-
It's debatable. Mappings start in the global configuration and "move" into profiles. The profile settings certainly apply to members. You want to change that. I don't know :) |
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
It's debatable. Mappings start in the global configuration and "move" into profiles. The profile settings certainly apply to members. You want to change that. I don't know :)