嗨,我想从 DB 中选择 4 列,然后选择到列表
public struct keyData
{
public int pid;
public int sid;
public string proid;
public string title;
}
Entities dbconn = new Entities();
List<keyData> temRes = (
from viewData in dbconn.vw1
join hData in dbconn.tableH
on new { pid= (int)viewData.pid, proid= viewData.proid}
equals new { pid= (int)hData .pid, proid= hData .proid}
into joinSet
from joinUnit in joinSet.DefaultIfEmpty()
where joinUnit == null
select new { pid= (int)viewData.pid, sid= (int)viewData.sid, proid= viewData.proid, Title=viewData.Title }
).ToList();
然后它说:
错误 3 无法隐式转换
type 'System.Collections.Generic.List<AnonymousType#1>'
至'System.Collections.Generic.List<hl.Program.keyData>'
谢谢
使用 MarcinJuraszek 的想法
它给了我:
Only parameterless constructors and initializers are supported in LINQ to Entities