[bug]不包含“AsNoTracking”的定义
摘要
在使用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<T> AsNoTracking<T>(this IQueryable<T> 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);
[bug]不包含“AsNoTracking”的定义的更多相关文章
- C# dynamic类型报错:“object”不包含“xxx”的定义
一.起因: 最近在做的一个项目,因为很多地方要用到同一套流程.为了后期维护,要求将共用流程进行抽离,创建为一个公用的类库.在抽离之前程序运行是没有问题的,然而在抽离之后就得到了如题错误: object ...
- 记dynamic的一个小坑 -- RuntimeBinderException:“object”未包含“xxx”的定义
创建一个控制台程序和一个类库, 在控制台创建一个匿名对象,然后再在类库中访问它,代码如下: namespace ConsoleApplication1 { class Program { static ...
- 包含为 HTTP 定义的状态代码的值(枚举)
using System; namespace System.Net { // 摘要: // 包含为 HTTP 定义的状态代码的值. public enum HttpStatusCode { // 摘 ...
- “IAsyncOperation<StorageFile>”不包含“GetAwaiter”的定义
错误 CS4036 "IAsyncOperation<StorageFile>"不包含"GetAwaiter"的定义,并且找不到可接受类型为&quo ...
- <转>记dynamic的一个小坑 -- RuntimeBinderException:“object”未包含“xxx”的定义
→转载地址← 创建一个控制台程序和一个类库, 在控制台创建一个匿名对象,然后再在类库中访问它,代码如下: namespace ConsoleApplication1 { class Program { ...
- 记dynamic的一个小坑 -- RuntimeBinderException:“object”未包含“xxx”的定义
from:http://blog.csdn.net/feiyun0112/article/details/39697955 创建一个控制台程序和一个类库, 在控制台创建一个匿名对象,然后再在类库中访问 ...
- webAPI中“System.Web.Http.HttpConfiguration”不包含“EnableSystemDiagnosticsTracing”的定义解决办法
webAPI中“System.Web.Http.HttpConfiguration”不包含“EnableSystemDiagnosticsTracing”的定义 今天从 运行 WebAPI 工程的代码 ...
- Xamarin.Android 开发,生成时提示“Resource.Drawable”未包含“BG”的定义
Xamarin Android提示Resource.Drawable”未包含“BG”的定义错误信息:error CS0117: '“Resource.Drawable”未包含“BG”的定义Xamari ...
- 关于CS1061报错(XX不包含XXX的定义,并且找不到类型为XX的第一个参.....)的一种可能的解决的办法
在我编程中,我遇到了一个这样的报错, 可是我引用的product类中又确实定义了这么一个方法, protected void BindPageData(int categoryID) { Produc ...
随机推荐
- C# 利用VS中的插件来打包并发布winfrom程序
1.先在VS 的扩展更新中搜索此插件[2015 installer Projects],点击下载,安装需要关闭VS 2.安装完毕之后新建项目 3.选择“application folder”项,然后在 ...
- IE9的「console未被定义」错误
IE从IE8+才支持console物件,但如上图所示,网页明明是IE9标准模式,为什么IE9却说console物件不存在? 但进行侦错,console.log()却又正常! 原因: IE8/IE9要先 ...
- Atom 清空残余数据
rm -rf ~/.atom rm /usr/local/bin/atom rm /usr/local/bin/apm rm ~/Library/Preferences/com.github.atom ...
- windows 系统安装git的方法
windows 系统安装git的方法 msysgit是Windows版的Git,从https://git-for-windows.github.io下载 安装默认步骤,一步步安装即可 安装完成后,在开 ...
- SpaceSyntax【空间句法】之DepthMapX学习:第四篇 凸多边形图分析[未完]
这一篇正式讲解分析类型中的第一个,凸多边形分析,流程图参照上一篇的. 博客园/B站/知乎/CSDN @秋意正寒(我觉得这一篇肯定很多盗图的,那么我在版头加个本篇地址吧) https://www.cnb ...
- 安装ORACLE时 各Linux版本下载地址
oracle linux :https://edelivery.oracle.com/osdc/faces/SearchSoftware 需要注册oracle账号 redhat官方下载 https:/ ...
- Storm的acker确认机制
Storm的acker消息确认机制... ack/fail消息确认机制(确保一个tuple被完全处理) 在spout中发射tuple的时候需要同时发送messageid,这样才相当于开启了消息确认机制 ...
- Installation failed with message...It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
错误弹窗如图: Installation failed with message Failed to finalize session: INSTALL_FAILED_TEST_ONLY:instal ...
- Mac终端配置,DIY你的Terminal (iTerm 2 + Oh My Zsh)
使用mac osx一年以来,自带的Terminal终端一直都是白底黑字,食之无味,越来越缺乏新鲜感,怎么也得想个法子来刺激下眼球. 不然花那么多大洋买你回来是要哪般,难道真是为来学习工作??? 怎么可 ...
- sql左右连接的区别
数据表的连接有: 1.内连接(自然连接): 只有两个表相匹配的行才能在结果集中出现 2.外连接: 包括 (1)左外连接(左边的表不加限制) (2)右外连接(右边的表不加限制) (3)全外连接(左右两表 ...