【发布时间】:2019-05-13 18:16:58
【问题描述】:
我有一个 linq 查询,它从表中返回多行,我想获取行数,并将结果从 System.Data.Entity.Infrastructure.DbQuery 更改为 List。 strUserID 不是客户服务表的主键。
var AllCustomerServices = from service in _context.CustomerServices
where service.strUserID == Session["userID"].ToString()
select service;
以下代码抛出异常:
if (AllCustomerServices.Count() > 0)
{
List<CustomerServices> cstSrvs = AllCustomerServices.ToList();
}
例外:
“AllCustomerServices.ToList()”引发了“System.NotSupportedException”类型的异常 [NotSupportedException:LINQ to Entities 无法识别方法 'System.Object get_Item(System.String)' 方法,并且该方法无法转换为存储表达式。]
【问题讨论】:
-
您好。您能否提供完整的异常堆栈?
-
@JuanR [NotSupportedException: LINQ to Entities 无法识别方法 'System.Object get_Item(System.String)' 方法,并且此方法无法转换为存储表达式。]
标签: c# asp.net linq model-view-controller