开发者

Is it possible to map an ienumerable to a bool using automapper?

开发者 https://www.devze.com 2023-02-05 00:30 出处:网络
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()?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号