Hi All,
I Need to filter the excel file based on starts with value by using linq query.
Can anyone please help me.
ex- i have column with the header name of CD
I need to filter the rows if it starts with D or E or K or L or R or S
Hi All,
I Need to filter the excel file based on starts with value by using linq query.
Can anyone please help me.
ex- i have column with the header name of CD
I need to filter the rows if it starts with D or E or K or L or R or S
Test with:
filteredDt = dt.AsEnumerable.Where(Function(r) {"D", "E", "K", "L", "R", "S"}.Any(Function(x) r("CD").ToString.ToUpper().StartsWith(x)))
Sorry, I was not at my computer so I couldn’t test. You need to add .CopyToDataTable()
also to make it work. Yes both dt and filteredDt should be DataTable.
Thanks mate!! this works fine, One last query please what if i have to filter with only one value which means starts with S.
filteredDt = dt.AsEnumerable.Where(Function(r) (“S”)(Function(x) r(“CD”).ToString.ToUpper().StartsWith(x))).copytodatatable()
does this work?
For checking one letter:
filteredDt = dt.AsEnumerable.Where(Function(r) r("CD").ToString.ToUpper().StartsWith("S")).CopyToDataTable()
Thanks a ton both works fine
If possible share me a link where i can learn query by myself
Here is the Tutorial for LINQ @ashokkumar_e
Regards
Gokul
Refer this learning doc @ashokkumar_e
Regards
Gokul
[quote=“[HowTo] Overview on different options for grouping data and processing the groups, post:1, topic:290708”]
ping data and processing the grouped data is a common scenario e.g. when the grouped data is to aggregate like summing up, find maximum, get the average or concatening items. Lets have a look on following data: [grafik] A possible scenario could be: Create a report containing follow
[/quote]
Thanks @Gokul