I have a table that holds stock items. These stock items have the following properties
public class StockItem
{
public int BrandId { get; set; }
public int ModelId { get; set; }
public decimal Price { get; set; }
public int StoreId { get; set; }
}
Where StoreId can be either 1 (Store A) or 2 (Store B)
I want to group these items to get the following result
BrandId
ModelId
Count in Store A
count in Store B
I have used group by
clause before but not in this way. How should I write the linQ statement to accomplish my task?
To summarize I have the following records
Id BrandId ModelId Price StoreId
=========================================
1 1 1 11 1
2 1 1 11 1
3 1 2 12 1
4 1 2 12 2
5 1 1 11 2
and trying to get the following result
BrandId ModelId CountInStoreA CountInStoreB
=================================================
1 1 2 1
1 2 1 1