asp.net MVC EF取集合 query.ToList() 错了吗?
varquery=uofw.MsqAutomaticSendSwitchs.AsQueryable();query=query.Where(b=>b.Org_ID2==o...
var query = uofw.MsqAutomaticSendSwitchs.AsQueryable();
query = query.Where(b=>b.Org_ID2==orgId2);
List<MsgAutomaticSendSwitchs> msgList = new List<MsgAutomaticSendSwitchs>();
foreach(var item in query.ToList()){
MsgAutomaticSendSwitchs ms = new MsgAutomaticSendSwitchs()
{
Id = item.Id,
Org_ID2 = item.Org_ID2,
Org_ID3 = item.Org_ID3,
FinanceMsg = item.FinanceMsg,
OtherMsg = item.OtherMsg
};
msgList.Add(ms);
}
// List<MsgAutomaticSendSwitchs> msgList = query.Select(t => new MsgAutomaticSendSwitchs { Id=t.Id, Org_ID2=t.Org_ID2,Org_ID3=t.Org_ID3,FinanceMsg=t.FinanceMsg,OtherMsg=t.OtherMsg}).ToList();
return new Vm_MsgAutomaticSendSwitch { FinancialList = msgList, FinanTotalCount = msgList.Count };
An error occurred while executing the command definition. See the inner exception for details. 展开
query = query.Where(b=>b.Org_ID2==orgId2);
List<MsgAutomaticSendSwitchs> msgList = new List<MsgAutomaticSendSwitchs>();
foreach(var item in query.ToList()){
MsgAutomaticSendSwitchs ms = new MsgAutomaticSendSwitchs()
{
Id = item.Id,
Org_ID2 = item.Org_ID2,
Org_ID3 = item.Org_ID3,
FinanceMsg = item.FinanceMsg,
OtherMsg = item.OtherMsg
};
msgList.Add(ms);
}
// List<MsgAutomaticSendSwitchs> msgList = query.Select(t => new MsgAutomaticSendSwitchs { Id=t.Id, Org_ID2=t.Org_ID2,Org_ID3=t.Org_ID3,FinanceMsg=t.FinanceMsg,OtherMsg=t.OtherMsg}).ToList();
return new Vm_MsgAutomaticSendSwitch { FinancialList = msgList, FinanTotalCount = msgList.Count };
An error occurred while executing the command definition. See the inner exception for details. 展开
1个回答
展开全部
List<MsgAutomaticSendSwitchs> msgList = uofw.MsqAutomaticSendSwitchs
.Where(b=>b.Org_ID2==orgId2)
.Select(m=>new MsgAutomaticSendSwitchs()
{
Id = m.Id,
Org_ID2 = m.Org_ID2,
Org_ID3 = m.Org_ID3,
FinanceMsg = m.FinanceMsg,
OtherMsg = m.OtherMsg
}).ToList();
追问
An error occurred while executing the command definition. See the inner exception for details.
uofw.MsqAutomaticSendSwitchs.AsQueryable().Where()才行。但还是报错
追答
你看下具体的异常是什么啊~
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询