码迷,mamicode.com
首页 > 其他好文 > 详细

报错:System.NotSupportedException: LINQ to Entities does not recognize the method

时间:2015-04-24 16:15:45      阅读:291      评论:0      收藏:0      [点我收藏+]

标签:

 

报错:System.NotSupportedException: LINQ to Entities does not recognize the method ...... get_Item(Int32)‘ method, and this method cannot be translated into a store expression.

 

在控制器中有如下一段代码:

 

var tempList = SomeService.LoadEntities(c => c.DelFlag == (short)DelFlagEnum.Normal);
var result = from l in tempList
             select new { n = l.Name, a = l.Age };

 

LoadEntities方法返回的类型是IQueryable<T>,如果要对集合用Select方法,在用Select方法之前需要ToList一下。

 

修改成:

 

var result = from l in tempList.ToList()
             select new { n = l.Name, a = l.Age };

报错:System.NotSupportedException: LINQ to Entities does not recognize the method

标签:

原文地址:http://www.cnblogs.com/darrenji/p/4453593.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!