Reputation: 11
I have this code:
public class Draw
{
public int DrawId { get; set; }
public virtual ICollection<Figure> Figures { get; set; }
}
public class Figure {
public Type type { get; set; }
public double Area { get; set; }
}
public enum Type { Square = 0, Triangle = 1, Circle = 2}
If I have a list of objects Draw, how can make a linq query to select all Draws with at least two figures with area over 5 of at least two different types.
Upvotes: 0
Views: 141
Reputation: 79441
var query = draws.Where(draw => draw.Figures
.Where(figure => figure.Area > 5)
.Select(figure => figure.type)
.Distinct()
.Count() >= 2);
Upvotes: 1