我在數據訪問層中有以下功能,但我在我的RETURN語句中收到以下錯誤。對DataTable類型錯誤的LINQ查詢
爲方法 'System.Data.DataTableExtensions.CopyToDataTable(System.Collections.Generic.IEnumerable)' 類型參數不能從使用推斷。嘗試 指定類型參數 明確
我的代碼是:
DL.FVRGDataContext db = new FVRGDataContext();
public DataTable getRestaurants(string cuisineName)
{
var cuisineIdFind = from CUISINE in db.CUISINEs
where CUISINE.CUISINE_NAME == cuisineName
select CUISINE.CUISINE_ID;
var restaurantList = from RESTAURANT in db.RESTAURANTs
where RESTAURANT.CUISINE_ID == 2
orderby RESTAURANT.REST_NAME ascending
select i;
DataTable result = new DataTable();
result = restaurantList.CopyToDataTable();
return result;
}
我很驚訝'餐廳列表'任務沒有失敗 - 你在這裏選擇的'我'是什麼? –
**爲什麼地球上**你是否使用LINQ獲取'Restaurant'列表,然後將它轉換回klunky,很難使用的'DataTable' .....根本沒有任何意義對我來說 - 但那只是我... –