How is a set partitioned into valid and invalid items using LINQ?
Posted
by
Aaron Anodide
on Stack Overflow
See other posts from Stack Overflow
or by Aaron Anodide
Published on 2012-06-26T19:48:38Z
Indexed on
2012/06/26
21:16 UTC
Read the original article
Hit count: 156
c#
|linq-to-objects
Is there a way to write a single LINQ expression to get the same result of the following code?
var validations = new Func<conversion, bool>[] {
c => c.affiliate.affiliate_id > 0,
c => c.campaign_id > 0
};
var invalidConversions = from c in extractedConversions
where validations.Any(valid => !valid(c))
select c;
var validConversions = from c in extractedConversions
where validations.All(valid => valid(c))
select c;
© Stack Overflow or respective owner