Please tell me how to write the result of a query in a DataTable?
var result = from clients in Clients_dt.AsEnumerable()
join cities in Cities_dt.AsEnumerable()
on clients.Field<int> ("CityId") equals cities.Field<int> ("ID") into ClientCityGroup
from subCities in ClientCityGroup.DefaultIfEmpty()
select new
{
Name = clients.Field <string> ("Name"),
City = subCities.Field <string> ("Name")
};
I tried using CopyToDatatable().
CopyToDataTable only works if the input is a DataTable. You have to create the DataTable before you can add data to the table.