Linq101-QueryExecution
using System;
using System.Linq; namespace Linq101
{
class QueryExecution
{
/// <summary>
/// The following sample shows how query execution is deferred until the query is enumerated at a foreach statement.
/// </summary>
public void Linq99()
{
int[] numbers = new int[] { , , , , , , , , , }; int i = ; //延迟执行
var q = from n in numbers select ++i; foreach (int n in q)
{
Console.WriteLine("n={0},i={1}", n, i);
}
} /// <summary>
/// The following sample shows how queries can be executed immediately with operators such as ToList().
/// </summary>
public void Linq100()
{
int[] numbers = new int[] { , , , , , , , , , }; int i = ; //ToList->立即执行
var q = (from n in numbers select ++i).ToList(); foreach (int n in q)
{
Console.WriteLine("n={0},i={1}", n, i);
}
} /// <summary>
/// The following sample shows how, because of deferred execution, queries can be used again after data changes and will then operate on the new data.
/// </summary>
public void Linq101()
{
int[] numbers = { , , , , , , , , , }; //可重用
var lowNumbers = from n in numbers
where n <=
select n; Console.WriteLine("First run numbers <=3:");
foreach (int number in lowNumbers)
{
Console.WriteLine(number);
} lowNumbers = (from n in numbers select -n).ToArray(); Console.WriteLine("Second run numbers <=3:");
foreach (int number in lowNumbers)
{
Console.WriteLine(number);
}
}
}
}
Linq101-QueryExecution的更多相关文章
- (十三)数据库查询处理之QueryExecution(2)
(十三)数据库查询处理之QueryExecution(2) 实验室这一周真的忙爆(虽然都是各种打杂的活)所以拖了很久终于在周末(摸鱼)把实验3做完了.同时准备把和查询这一块有关的博客补一下.然后就进入 ...
- Linq编程101例
原文地址:101 LINQ Samples in C# Part1 - Restriction Operators Part2 - Projection Operators Part3 - Parti ...
- spark dataframe unionall
今天本来想写一个spark dataframe unionall的demo,由于粗心报下面错误: Exception in thread "main" org.apache.spa ...
- spark on yarn 提交任务出错
Application ID is application_1481285758114_422243, trackingURL: http://***:4040Exception in thread ...
- Spark入门实战系列--6.SparkSQL(中)--深入了解SparkSQL运行计划及调优
[注]该系列文章以及使用到安装包/测试数据 可以在<倾情大奉送--Spark入门实战系列>获取 1.1 运行环境说明 1.1.1 硬软件环境 线程,主频2.2G,10G内存 l 虚拟软 ...
- Linq 101 工具和源码
工具如图: 源码: https://git.oschina.net/yudaming/Linq101
- Jena语义Web开发101
2015/05/28更新 代码在 https://github.com/zhoujiagen/semanticWebTutorialUsingJena 前言 该手册参考和扩展“Hebeler J, F ...
- Jena TDB 101 Java API without Assembler
Update on 2015/05/12 ongoing tutorials site on https://github.com/zhoujiagen/semanticWebTutorialUsin ...
- Jena Fuseki 101
前言 正如其承诺的那样 Expose your triples as a SPARQL end-point accessible over HTTP. Fuseki provides REST-sty ...
随机推荐
- matlab取整
matlab取整 Matlab取整函数有: fix, floor, ceil, round.取整函数在编程时有很大用处.一.取整函数1.向零取整(截尾取整)fix-向零取整(Round towards ...
- Lua table使用
days = {"Sunday", "Monday", "Tuesday", "Wednesday", "Th ...
- 【POJ】2513 Colored Sticks
字典树+并查集. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 5000 ...
- -_-#【Better JS Code】严格模式
要在整个脚本中启用严格模式,可以在顶部添加如下代码: "use strict"; 这行代码看起来像是字符串,而且也没有赋值给任何变量,但其实它是一个编译指示,用于告诉支持的 Jav ...
- LNMP一键安装脚本
#!/bin/bash #LNMP(Fastcgi) #CentOS + MySQL 5.5 #-- iptables -F iptables -X iptables -Z iptables -A I ...
- 奔跑的xiaodao
http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=2086 很明显的一个二分题目.因为要 ...
- iconv gbk字符转utf8字符
直接上代码 bool gbk2utf8(const char* src, char* dest, size_t inlen) { const char *inbuf = src; size_t out ...
- Nodejs in Visual Studio Code 07.学习Oracle
1.开始 Node.js:https://nodejs.org OracleDB: https://github.com/oracle/node-oracledb/blob/master/INSTAL ...
- H - Parity game-poj1733(需要离散化)
题意:给一个序列这个序列都是由0和1组成,现在随意拿出来一个序列,然后说出他的和是奇数还是偶数,因为有可能存在假话,让你判断前多少条没有假话,也就是查找第一个假话的位置-1 ///////////// ...
- android 客户端 和 新浪微博如何打通的
微博SDK 为开发者 提供访问oauth2.0 授权认证,并集合sso登录功能,使用第三方应用可通过 新浪微博的 登录操作 提供微博分享功能,可直接通过微博客户端分享微博 名词解释 AppKey 分配 ...