开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜