迟来的零碎笔记
2016-03-01 16:21
344 查看
1.
请教个问题:
楼主文中说“因为 IQueryable 是延迟查询,只有在执行 AsEnumerable 的时候,才会真正去查询”。
我调试程序过程中,在单步执行AsEnumerable()时,使用SQL Server Profiler并没有检测到有sql语句执行...
支持(0)反对(0)
回复引用
#107楼[楼主] 2015-08-28 18:43 田园里的蟋蟀
@_天光云影
嗯,我测试了下,确实没有执行SQL,需要ToList,或者FirstOrDefault,说明:
Calling AsEnumerable() does not guarantee that the results will be executed immediately.
IQueryable is the interface that allows LINQ to SQL to perform its magic. IQueryable implements IEnumerable so when you call AsEnumerable(), nothing really happens.
To force query execution, you must call ToList().
来自:Am I misunderstanding LINQ to SQL .AsEnumerable()?
请教个问题:
楼主文中说“因为 IQueryable 是延迟查询,只有在执行 AsEnumerable 的时候,才会真正去查询”。
我调试程序过程中,在单步执行AsEnumerable()时,使用SQL Server Profiler并没有检测到有sql语句执行...
支持(0)反对(0)
回复引用
#107楼[楼主] 2015-08-28 18:43 田园里的蟋蟀
@_天光云影
嗯,我测试了下,确实没有执行SQL,需要ToList,或者FirstOrDefault,说明:
Calling AsEnumerable() does not guarantee that the results will be executed immediately.
IQueryable is the interface that allows LINQ to SQL to perform its magic. IQueryable implements IEnumerable so when you call AsEnumerable(), nothing really happens.
To force query execution, you must call ToList().
来自:Am I misunderstanding LINQ to SQL .AsEnumerable()?
相关文章推荐
- SPRING IN ACTION 第4版笔记-第二章-004-Bean是否单例
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
- Java锁机制
- myeclipse
- myeclipse
- 对一个字符串重新排列要求字母在钱数字在后,且不改变字母数字间的原有顺序
- POJ-3261 Milk Patterns (后缀数组 最长k次重复子串)
- SPRING IN ACTION 第4版笔记-第二章-003-以Java形式注入Bean、@Bean的用法
- 在不花一分钱的情况下,如何验证你的创业想法是否可行?《转》
- cookies
- Java多线程(四)——线程阻塞四种情况与守护线程
- Python抓取网页图片
- idean Error:java: 无效的目标发行版: 1.8
- myfn.tld文件错误
- hdoj 2062 Subset sequence 【思维】
- 第12章、布局Layouts之LinearLayout线性布局(从零开始学Android)
- imx6ul evk板子 QSPI nor启动记录(3) 启动qspi nor 系统
- mysql 错误 SQL Error: 1366: Incorrect string value: "\xE8\xAF\xA6\xE7\xBB\x86…" for column "address" a
- jq 删除数组中的元素
- NSTimer 使用小结