In .NET 3.5, ASP.NET using C#
From the below Query,
var query = table.AsEnumerable()
.Where(p => p.Field<string>("Customer_Code") == "1001")
.Select(p => new
{
Location = p.Field<string>("Location"),
Country = p.Field<string>("Country")
})
.Distinct();
I want to compare the resultant query results such as Location, Country with each DataRow of a DataTable Location and Country
OR In Reverse way,
I want to compare each Query result with each DataTable Row
How can i perform the same?
Sample Datatable:
Location Country
Bangalore India
Hyderabad India
Florida USA
London UK
Delhi India
How about you do the following to check for a match:
Note:
*A
.Where(...).Count >0check might be better dependant on what you will find in the query. If you expect multiple hits, use.Where()instead of.SingleOrDefault()New idea
If you don’t mind processing your DataTable and storing it in an IEnumerable, you could use LINQ-joins to connect the two lists. A bit harder but I think it will be more efficient.