我有這個類:GROUP BY列表<Item>
public class Item
{
public virtual int32 Id { get; set; }
public virtual Previa Previa { get; set; }
public virtual Product Product { get; set; }
public virtual Int32 Quantity { get; set; }
public virtual Decimal Price { get; set; }
public virtual Decimal Total { get; set; }
}
,現在我需要一個查詢來查找數據庫中的每個項目,按產品,數量與總的總和。 爲了找到每一個項目,我使用:
public List<Item> FindItem(int IdProduct = 0)
{
var retorno = (from c in Session.Query<Item>()
select c);
if (IdProduto > 0)
retorno = retorno.Where(x => x.Product.Id == IdProduct)
return retorno.ToList<Item>();
}
但我不知道如何分組這些項目。有人可以幫我嗎?
什麼是grupo?那個是從哪裏來的?將這些項目分組是什麼意思 - 你的意思是? – Oded 2012-04-13 12:42:00
是否有許多產品具有相同的'IdProduct'? – 2012-04-13 12:44:10
Oded,對不起......現實中的「grupo」是「retorno」。我編輯。 – JohnyMoraes 2012-04-13 12:54:41