这是行不通的。将 Null 返回到 dept_list。
var dept_list = ((from map in DtMapGuestDepartment.AsEnumerable()
where map.Field<Nullable<long>>("Guest_Id") == 174
select map.Field<Nullable<long>>("Department_id")).Distinct())as IEnumerable<DataRow>;
DataTable dt = dept_list.CopyToDataTable(); //dept_list comes null here
这可以按需要工作。
var dept_list = from map in DtMapGuestDepartment.AsEnumerable()
where map.Field<Nullable<long>>("Guest_Id") == 174
select map;
DataTable dt = dept_list.CopyToDataTable(); //when used like this runs correct.
我在这里犯了什么错误。?