博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[bug]不包含“AsNoTracking”的定义
阅读量:6969 次
发布时间:2019-06-27

本文共 1768 字,大约阅读时间需要 5 分钟。

摘要

在使用ef做查询优化的时候我们会用到AsNoTracking方法,但如果不引入命名空间,你就会出现不包含“AsNoTracking”的定义的错误。

解决办法

引入命名空间:System.Data.Entity

AsNoTracking是对IQueryable的扩展,看它的定义就可以知道,代码片段如下:

//        // 摘要:         //     Returns a new query where the entities returned will not be cached in the        //     System.Data.Entity.DbContext or System.Data.Entity.Core.Objects.ObjectContext.        //     This method works by calling the AsNoTracking method of the underlying query        //     object. If the underlying query object does not have an AsNoTracking method,        //     then calling this method will have no affect.        //        // 参数:         //   source:        //     The source query.        //        // 类型参数:         //   T:        //     The element type.        //        // 返回结果:         //     A new query with NoTracking applied, or the source query if NoTracking is        //     not supported.        public static IQueryable
AsNoTracking
(this IQueryable
source) where T : class;
//        // 摘要:         //     Returns a new query where the entities returned will not be cached in the        //     System.Data.Entity.DbContext or System.Data.Entity.Core.Objects.ObjectContext.        //     This method works by calling the AsNoTracking method of the underlying query        //     object. If the underlying query object does not have an AsNoTracking method,        //     then calling this method will have no affect.        //        // 参数:         //   source:        //     The source query.        //        // 返回结果:         //     A new query with NoTracking applied, or the source query if NoTracking is        //     not supported.        public static IQueryable AsNoTracking(this IQueryable source);

 

转载地址:http://rtisl.baihongyu.com/

你可能感兴趣的文章
Android Studio的SVN Performing VCS Refresh/Commit 长时间不结束
查看>>
简单编写makefile文件,实现GCC4.9编译项目,增加boost库測试等等。。
查看>>
Android-Volley网络通信框架(二次封装数据请求和图片请求(包含处理请求队列和图片缓存))...
查看>>
【一步步学OpenGL 20】 -《点光源》
查看>>
工作总结 获取html 标签 自定义属性值 根据html 自定义属性 获取 到标签...
查看>>
帧中继网络 (转)
查看>>
同步与异步 阻塞与非阻塞
查看>>
spring boot项目中处理Schedule定时任务
查看>>
最简单易懂的SpringCloudSleuth教程
查看>>
为什么可视化数据有一定的误差值?
查看>>
Android应用安全风险与防范
查看>>
硅谷亿万富翁彼得·泰尔的神秘大数据公司在新西兰遭审查
查看>>
参加工业软件与制造业融合发展高峰论坛 用友3.0加速落地
查看>>
赌Impinj就是赌RFID行业
查看>>
亚马逊数据专家十年经验总结:成为数据科学家的关键四步
查看>>
普京签订反恐法:互联网公司将增加数十亿美元成本
查看>>
微软详细说明了用户在Word和Outlook中的前10个语法错误
查看>>
如何弱化因不同软件测试人员测试而引发的BUG率上涨的现象?
查看>>
SAP云计算产品线关键功能扩展升级
查看>>
Com0com+com2tc 试用
查看>>