Get value by dynamic column names using LINQ to Datatable

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
I have a datatable which has multiple values but few column names are dynamic there. see screen shot of my data table.

1569561.png

2010 FY 2011 FY these column names are dynamic. now i have to fetch data from above datatable by LINQ. i use these condition to get data for 2010 FY.


here is my LINQ query but i do not know how to mention dynamic column name like 2010 FY.

var data = dt.AsEnumerable()
.Where(x => x.Field<string>("Section") == "Consensus Model"
&& x.Field<string>("Line Item") == "Net Sales" && x.Table.Columns["2010 FY"]).ToList();
i need to fetch data for 2010 FY along with other condition like when Section is Consensus Model and Line Item is Net Sales


so please guide me how to compose LINQ query which fetch 2010 FY's Data which is 65225 with mentioning Section & Line Item.

thanks

Continue reading...
 
Back
Top