我有这个类: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