使用Linq to Entities的时候发生如下异常:

Unable to create a constant value of type 'Closure type'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.

  1. var histroyList = data.TransMemoryHistory.Where(c => c.TransMemorys.TMID == tmid && c.UsedType != (int)usedType);

termUsedType是枚举类型。

这是因为Linq to Entities根据Where中的委托生成SQL语句,所以对里面的复杂程度(方法)有一定的限制,其中的(int)s就无法被正确翻译。但是也不完全会出现此错误。

要解 决这个问题,需要把这个(int)s过程放到外面来:

  1. int usedType = (int)termUsedType;
  2. var histroyList = data.TransMemoryHistory.Where(c => c.TransMemorys.TMID == tmid && c.UsedType != usedType);

Unable to create a constant value of type 'Closure type'的更多相关文章

  1. Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context.

    代码如下: var query = from s in db.LoginUserServices join ss in db.Services on s.ServiceType equals ss.C ...

  2. Unable to create the store directory. (Exception from HRESULT: 0x80131468)

    一个ASP.NET的程序,使用了MS ReportViewer报告控件,在用该控件导出生成Excel文件时,先是提示行不能超过65535. 这个是由于Excel2003的行限制的原因.由于修改成用Ex ...

  3. JVM虚拟机宕机_java.lang.OutOfMemoryError: unable to create new native thread

    原因:当前用户的系统最最大程序数数已达到最大值,使用ulimit -u可以看到是1024   解决办法:在当前用户下使用ulimit -u 65535 然后再执行jsp,一切ok     功能说明:控 ...

  4. Fatal error in launcher Unable to create process using 'dapppythonpython37python

    Fatal error in launcher: Unable to create process using '"d:\app\python\python37\python.exe&quo ...

  5. 记一次tomcat线程创建异常调优:unable to create new native thread

    测试在进行一次性能测试的时候发现并发300个请求时出现了下面的异常: HTTP Status 500 - Handler processing failed; nested exception is ...

  6. 解决Unable to create new native thread

    两种类型的Out of Memory java.lang.OutOfMemoryError: Java heap space error 当JVM尝试在堆中分配对象,堆中空间不足时抛出.一般通过设定J ...

  7. ArcEngine编辑保存错误:Unable to create logfile system tables

    通过ArcEngine对多个SDE中多个图层进行批量编辑处理,其中有部分图层在结束编辑的时候出现错误提示(部分图层可以,只有两个数据较多的图层保存失败). 错误信息:Unable to create ...

  8. Fatal error in launcher: Unable to create process using '"'

    今天遇到了 Fatal error in launcher: Unable to create process using '"' 这个问题,原来是我上次装python3.5的时候,pyth ...

  9. Genymotion创建下载模拟器的时候出现Unable to create Genymotion virtual devices:Connection timeout错误

    如图,如果Genymotion创建下载模拟器的时候出现Unable to create Genymotion virtual devices:Connection timeout错误,具体解决方法如下 ...

随机推荐

  1. js根据当前时间获取当前季度,月份,和第几周

    function jidu()  {   var getMonthWeek = function (a, b, c) {    var date = new Date(a, parseInt(b) - ...

  2. 在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错误的

    在MVC中添加授权认证配置之后报了这样的错 原因是在整个MVC项目中有两个Web.Config文件存在authentication节点,一个Web.Config文件在View目录下,一个在根目录下 解 ...

  3. C语言输出时的各种%

    d  以十进制形式输出带符号整数(正数不输出符号) o  以八进制形式输出无符号整数(不输出前缀O) x  以十六进制形式输出无符号整数(不输出前缀OX) u  以十进制形式输出无符号整数 f  以小 ...

  4. HTML 文本格式化<b><big><em><i><small><strong><sub><sup><ins><del>

    <b> 标签-粗体 定义和用法: <b>标签规定粗体文本. 提示和注释 注释:根据 HTML5 规范,在没有其他合适标签更合适时,才应该把 <b> 标签作为最后的选 ...

  5. H5页面左图右边文字如何布局

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  6. jquery 常用基础方法

    1 jquery常用方法: 2 取得标签元素里面内容与修改: 3 1.text()方法: 4 $(document).ready(function(){ 5 //alert("文档加载完毕& ...

  7. 不错的TOMCAT监控好工具probe

    Tomcat版本:6.0.41 Probe版本:2.3.3 一,Tomcat没有默认用户账号,故首先需要添加Tomcat用户账号 修改$CATALINA_HOME/conf/tomcat-users. ...

  8. Hibernate4和Mysql5.1以上版本创建表出错 type=InnDB

    在搭建springmvc框架时,底层使用hibernate4.1.8,数据库使用mysql5.1,使用hibernate自动生成数据库表 时,hibernate方言使用org.hibernate.di ...

  9. Huawei校招机试中的猴子吃桃问题

    //============================================================================ // Name : Monkey& ...

  10. 调用回调函数出现或者大循环出现has triggered a breakpoint

    triggered a breakpoint 的意思是触发一个断点.这个问题一般发生在程序运行过程中.下面是错误发生显示的信息:Windows has triggered a breakpoint i ...