Hello All,
I am facing an prob please help.
I have following class.
class Product
{
public int ProdCode { get; set; }
public decimal NetAmount { get; set; }
public List<int> BillDetailIds { get; set; }
}
In db there are two tables:
Table 1: Master table : containing following columns
BillId (PK), BillDate
Table 2: Details Table: containing following columns
BillDetailId (PK), BillId (FK), ProdCode, NetAmount
I want to show list from details table group by with Prodcode with sum of its amount. so i did below
var prodlist=Db.Details..GroupBy(x=>new{x.ProdCode}).select(x=>
new Product(){
ProdCode = Convert.ToInt32(x.FirstOrDefault().ProdCode),
NetAmount = x.Sum(s => s.Amount),
BillDetailIds=???
};
I'm stuck in BillDetailIds.
I need to store BillDetailIds on which groups is performed to create an Product object.
Help me please, thanks in advance