3
I have no idea how to do this consultation on LINQ. How can I from sales list. Separate the sales per hour, then group the products and add up the quantities sold?
public class Venda
{
public int Id {get;set;}
public DateTime DataHora {get;set;}
public List<ProdutoVendido> ProdutosVendidos {get;set;}
}
public class ProdutoVendido
{
public Produto Produto {get;set;}
public int Quantidade {get;set;}
}
public class Produto
{
public int Id {get;set;}
public string Nome {get;set;}
}
In SQL would look like this:
select hour(dthr_venda), nm_produto, sum(cd_qt) from produto_e_venda
join venda using(cd_venda)
join produto using (cd_produto)
group by cd_produto, hour(dthr_venda)
order by 1;
product_e_sale is the Product class?
– Laerte
Productovendido refers to product table_e_sale yes (:
– Latrova
The model looks wrong, and you’re using Entity ?
– user6026
But Productovendido has no Id?
– Laerte
I simplified, there are other properties.
– Latrova
Not because this table has two primary keys, being sales code and product code. I’m also using Effluent nhibernate to make the classes
– Latrova
Enter the codes completely if it is not difficult to answer :)
– user6026