【发布时间】:2011-06-30 13:37:55
【问题描述】:
我在数据访问层中有以下功能,但我在 RETURN 语句中收到以下错误。
方法的类型参数 '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;
}
【问题讨论】:
-
我很惊讶
restaurantList分配没有失败 - 你在这里选择的i是什么? -
而到底为什么你会使用 LINQ 获取
Restaurant的列表,然后将其转换回笨拙的、难以使用的DataTable... .. 对我来说根本没有任何意义 - 但这只是我......
标签: asp.net linq datatable types