I am trying to group by my table with multiple columns and checking if the grouping count is equal to 2. I have the query working for this part
var query = from product in Products
group by new { product.Product, product.Location, product.Customer } into grp
where grp.Count() != 2
The Product has an another property Category, which could only have two values “High” & “Low”.
How can I change this query to handle the check for Category in addition to the grouping count.
Product Location Customer Category
A X C1 High
A X C1 Low
A Y C1 High
A Y C1 Low
A Y C1 Low
B X C1 High
B X C1 Medium
In the example above, except for Product A at Location X and Customer C1, all other records are invalid. The Location Y has two Lows and Product B has a category Medium which is not part of the list: High & Low.
If you want to include only specific categories, use a
where ..expression: