Hi, Can you please provide an example of using LINQ query for a partial match in a data table? I cannot use Lookup because of partial match. Thanks a lot!!
may we ask you to share some sample data with us. Thanks
Hi @cury ,
If you are looking for generic skeletal logic to work with, then here are two examples:
One or more columns contains a given text->
Its always better to convert it to a List of DataRows instead of directly converting it to a DataTable.
A DataTable doesn’t accept null values i.e., if the entire Dataset you are evaluating doesn’t contain the given text, it will return zero results which the DataTable is allergic to.
After this, you can add an If Activity and pass this condition in →
Similarly, you can check if the entire DataSet itself contains a given text using this:
Dt.AsEnumerable().Where(Function(w) w.ItemArray.Any(Function(a) a.ToString.Trim.ToLower.Contains("texttomatchwith"))).ToList()
Like with the previous scenario, check if the List of DataRows is empty and not, and if it isn’t then assign it directly to a DataTable.
Dt.AsEnumerable().Where(Function(w) w.ItemArray.Any(Function(a) a.ToString.Trim.ToLower.Contains("texttomatchwith"))).CopyToDataTable()
I hope that has helped you get an idea of what the approach would be when dealing with such situations.
Thank you so much!
Glad I could help!
I’d appreciate it if you marked the answer as Solution so that others facing similar queries may benefit from it, and also so as to close this thread.
Have a nice day!
@ashwin.ashok Kindly can you please refer me to a good resource how to acquire this LINQ query knowledge. Thanks so much
Thanks very much @ppr.
@ppr has written a fantastic series on LINQ, which inspired me to pen my very own series which you can check out if you are interested.
I’m still in the process of writing it, and if you have any ideas or topics you’d like me to explore, the feel free to offer suggestions.
Thank you! Appreciate it.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.