Hi Everyone,
I have a datatable.
Now without writing this datatable as an excel file, I want to find
The value of address of person Tello using a linq query.
Can someone help me on this.
Thanks!
Hi Everyone,
I have a datatable.
Now without writing this datatable as an excel file, I want to find
The value of address of person Tello using a linq query.
Can someone help me on this.
Thanks!
Try out the below syntax
Str_var = (
From row in YourDataTableVariable
Where row(“Name”).ToString=“Tello”
Select row(“Address”)
).ToString
Where Str_var variable is type of string
Hope it solves your issue
Thanks
Robin
Hi
There are actually two ways to do this
Lookup datatable activity
Second one is with linq query links this
str_address = dt.AsEnumerable().Where(Function(a) a.Field(of String)(“Name”).ToString.Contains(“Tello”)).Copytodatatable().Rows(0)(“Address”).ToString
Cheers @satish_kumar
in activity level we would use filtrdatatable / lookup datatable.
When doin it with LINQ we have to respect the underlying base - (I)Enumerable. It expects a result of 0, 1 ore more match. To get back a string and also handling the case that it isn’t found we would do:
strAdress =
(From d in YourDataTableVar.AsEnumerable
Where d("Name").ToString.ToLower.Trim.Equals("Tello")
Select s=d("Address").toString).FirstOrDefault()
Also have a look here: