Friday, 6 September 2013

IEnumerable query = from p in data.AsEnumerable()

IEnumerable query = from p in data.AsEnumerable()

I'm using this query to filter some data with groupby "Client" + sum
amount and to fill a datagrid. I got an error in the "select" keyWord. Any
ideas how to fix this. Thanks in advance.
IEnumerable<DataRow> query = from p in data.AsEnumerable()
where (p.Field<string>("BS") == txtFilterbyBC.Text
&& p.Field<string>("YEAR") == txtYear.Text
&& p.Field<string>("RM") == txtRM.Text)
group p by p.Field<string>("Client") into g
select new
{
Name = g.Key,
Total = g.Sum(x =>
Convert.ToDouble(x.Field<double>("AMOUNT")))
};
System.Data.DataTable boundTable = query.CopyToDataTable<DataRow>();
dataGridView1.DataSource = boundTable;

No comments:

Post a Comment