Hi,I have datatable ,and and array of string and i want to compare datatable value with array values,after compare need those data in a datatable using linq query?
Below is an example:
arrStr={“not required”,“no template required”}
dt_table
and the final output will be in datatable
Output:
dt_Final
Anyone help me writing linq query for the above scenario.Thank you
lrtetala
(Lakshman Reddy)
9월 20, 2024, 6:14오전
2
Hi @yashashwini2322
Use below query
DT = (From row In DT.AsEnumerable()
Where arrStr.Contains(row("ColumnB").ToString)
Select row).CopyToDataTable
Input:
Output:
Regards,
Hi,Thanks for the query help but,same linq query is not working for the below table.Any modification needed for query.
lrtetala
(Lakshman Reddy)
9월 20, 2024, 7:21오전
4
@yashashwini2322
I’ve changed the query, try this
DT = (From row In DT.AsEnumerable()
Where arrStr.Any(Function(str) row("ColumnB").ToString.ToLower().Contains(str.ToLower()))
Select row).CopyToDataTable()
Regards,
lrtetala
(Lakshman Reddy)
9월 20, 2024, 8:34오전
6
@yashashwini2322
Try this
DT = (From row In DT.AsEnumerable()
Where arrStr.Any(Function(str) row("ColumnB").ToString().ToLower().Contains(str.ToLower()) AndAlso
row("ColumnA").ToString().ToLower() = "cs"
Select row).CopyToDataTable()
Regards,