I am developing a query with C #, but I have a problem to accomplish the same. I need to group by date.
Code:
public void BuscarVendaDeProdurtos_Saidas()
{
var data1 = Convert.ToDateTime(dateINI_Saida.Text);
var data2 = Convert.ToDateTime(dateFINI_Saida.Text);
var cod = Convert.ToInt64(textBox8.Text);
var pesquisa = from p in dc.ITEMVENDA
orderby p.CD_PRODUTO descending
where p.CD_PRODUTO == cod && p.Data_Venda >= data1 && p.Data_Venda <= data2
select new
{
p.NM_PROD,
p.Data_Venda,
p.QT_PRODV,
};
dataGridView2.DataSource = pesquisa.ToList();
Soma = 0;
foreach (DataGridViewRow dr in dataGridView2.Rows)
Soma += Convert.ToDecimal(dr.Cells[2].Value);
textBox12.Text = Convert.ToString(string.Format("{0:n}", Soma));
}
This search returns this:
Data Produto Qt
20/10/2017………………. 3
20/10/2017 …………….. 1
I need something like this:
Data Produto Qt
20/10/2017………………. 4
A single date with its sums added up.