报错: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的更多相关文章

  1. c#重命名文件,报错“System.NotSupportedException”类型的未经处理的异常在 mscorlib.dll 中发生”

    修改远程服务器的文件名,报错“System.NotSupportedException”类型的未经处理的异常在 mscorlib.dll 中发生”,“System.NotSupportedExcept ...

  2. 关于.ToList(): LINQ to Entities does not recognize the method ‘xxx’ method, and this method cannot be translated into a store expression.

    LINQ to Entities works by translating LINQ queries to SQL queries, then executing the resulting quer ...

  3. LINQ to Entities does not recognize the method 'System.DateTime AddDays(Double)' method, and this method cannot be translated into a store expression.

    NormalSubmission=analysis.Count(x=>x.FinishTime<= endTime.AddDays(1))报错linq不能识别 => var endT ...

  4. LINQ to Entities does not recognize the method , and this method cannot be translated into a store expression 解决办法

    根据用户输入的起始日期,查询以起始日期开始的前20条记录,在ASP.NET MVC的Controller代码中这样写: var Logs = db.Log.Take(20); if (!string. ...

  5. LINQ to Entities does not recognize the method 'System.DateTime ToDateTime(System.String)' method

    System.Data.Objects.EntityFunctions和System.Data.Objects.SqlClient.SqlFunctions中的方法进行比较,如下 where Syst ...

  6. LINQ to Entities does not recognize the method 'Int32 ToInt32(System.String)' method, and this method cannot be translated into a store expression

    if (!string.IsNullOrEmpty(FarmWorkId)) { data = data.Where(p => p.TypeId == Convert.ToInt32(FarmW ...

  7. C# 调用win32 DLL报错 System.BadImageFormatException

    C# 调用win32 DLL报错  System.BadImageFormatException 项目右键属性->项目设计器->生成->平台->把'默认设置(任何 CPU)'改 ...

  8. 上传文件报错System.Net.ProtocolViolationException: 必须先将 ContentLength 字节写入请求流,然后再调用 [Begin]GetResponse。

    在上传文件的时候报错. 错误: System.Net.ProtocolViolationException: 必须先将 ContentLength 字节写入请求流,然后再调用 [Begin]GetRe ...

  9. Azure File挂载报错--System Error 1231

    背景信息: 1.Azure 虚拟机与Azure File位于同一区域 2.同一Azure File可以挂载到别的同型号的虚拟机上使用,唯独挂载到问题机器(test01)时出现如下报错:System E ...

随机推荐

  1. usb的一些网址

    一些关于usb的帖子.网址: usb gadget device g_ether.ko 做成usbnetwork http://bbs.csdn.net/topics/370120345 Linux ...

  2. Debian/Ubuntu安装WPS (转)

    卸载libreoffice sudo apt-get remove --purge libreoffice* 官网下载WPShttp://wps-community.org/downloads?vl= ...

  3. KNN算法的感受 1

    本来预计的打算是一天一个十大挖掘算法,然而由于同时要兼顾数据结构面试的事情,所以 很难办到,但至少在回家前要把数据挖掘十大算法看完,过个好年,在course上学习老吴的课程还是帮了我很大的忙,虽然浪费 ...

  4. vue里面使用Velocity.js

    英文文档:http://velocityjs.org/ https://github.com/julianshapiro/velocity 中文手册(教程):http://www.mrfront.co ...

  5. visual studio code插件精选

    HTML Snippets 超级实用且初级的 H5代码片段以及提示 HTML CSS Support 让 html 标签上写class 智能提示当前项目所支持的样式 JavaScript Atom G ...

  6. 【AtCoder】AGC026 题解

    A - Colorful Slimes 2 找相同颜色的一段,然后答案加上段长除2下取整 代码 #include <iostream> #include <cstdio> us ...

  7. sed匹配多行替换

    sed -i '/aaa/{:a;n;s/123/xyz/g;/eee/!ba}' yourfile 如题:aaa123123123123123eee怎么匹配aaa~eee(开始结束字符串确定),然后 ...

  8. Chrome浏览器被hao123劫持,浏览器主页会被篡改为 hao123等

    先放一个知乎帖子: https://www.zhihu.com/question/21883209 我就只放几个有效解决办法了,具体的可以看上边那个帖子 方案一:     删掉桌面上的chrome图标 ...

  9. matplotlib显示中文异常处理

    matplotlib显示中文 [做个记录,方便以后使用] [一般导入方式] import matplotlib.pyplot as plt [效果图] [方式一]FontProperties impo ...

  10. PocketMoney

    PocketMoney( Money.pas/cpp/c)Description学校为了表彰tsoi的优异成绩, m个领导每人都决定给tsoi的一些人发一些小红包.于是n个Tsoier排成一排,等待着 ...