今天下午做一高效分页,
var spdmList = from d in data
select d.spdm;
var resdata = from z in db.z_tz
where spdmList.Contains(z.spdm)
select z;
在resdata中加一个orderby 便会报错如:
var resdata = from z in db.z_tz
orderby z.id
where spdmList.Contains(z.spdm)
select z
报错详细为:Unknown column 'Extent1.spdm' in 'where clause'
只能tolist后再orderby
问题解决:
var spdmList = from d in data
select d.spdm;
var resdata = from z in db.z_tz
where spdmList.Contains(z.spdm)
select z;
改为
var spdmList = (from d in data
select d.spdm).ToList() ;
var resdata = from z in db.z_tz
orderby z.id
where spdmList.Contains(z.spdm)
select z ;
先spdmList 变为内存数据就OK