Is it possible to map an ienumerable to a bool using automapper?
I would like to map an ienumerable t开发者_如何学运维o a bool using automapper. Is this possible, the bool would be true if items exist in the ienumerable and false otherwise.
Have you tried Any()
?
Enumerable.Empty<string>().Any()
You can set up a mapping using Enumerable.Any
via
src => src.Sequence.Any()
where src
is represents your source object and Sequence
is a property on the source object that is an IEnumerable<T>
for some T
.
精彩评论