Please help the SQL Query in LINQ form – C# .NET 3.5
select distinct location, country from Customer where Customer_Code ='1001';
This is Query has no problem. Works fine in SQL. But getting error while i used the below LinQ query in ASP.NET code in LINQ format. Please help the same.
EDIT:
In ASP.NET code,
var Query2 = ds.Tables[0].AsEnumerable()
.Where(p => p.Field<string>("Customer_Code") == "1001")
.Select(p => new {p.Field<string>("Location"),p.Field<string>("Country")});
ERROR:
Error: Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.
Kindly help!!!
Something like:
The key here is the use of an anonymous type that serves as a tuple holding a customer’s location and country.
EDIT: After your edit, it looks like you are using data-tables, not LINQ to SQL / Entities.
In which case, you probably want something like: