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的更多相关文章

  1. (十三)数据库查询处理之QueryExecution(2)

    (十三)数据库查询处理之QueryExecution(2) 实验室这一周真的忙爆(虽然都是各种打杂的活)所以拖了很久终于在周末(摸鱼)把实验3做完了.同时准备把和查询这一块有关的博客补一下.然后就进入 ...

  2. Linq编程101例

    原文地址:101 LINQ Samples in C# Part1 - Restriction Operators Part2 - Projection Operators Part3 - Parti ...

  3. spark dataframe unionall

    今天本来想写一个spark dataframe unionall的demo,由于粗心报下面错误: Exception in thread "main" org.apache.spa ...

  4. spark on yarn 提交任务出错

    Application ID is application_1481285758114_422243, trackingURL: http://***:4040Exception in thread ...

  5. Spark入门实战系列--6.SparkSQL(中)--深入了解SparkSQL运行计划及调优

    [注]该系列文章以及使用到安装包/测试数据 可以在<倾情大奉送--Spark入门实战系列>获取 1.1  运行环境说明 1.1.1 硬软件环境 线程,主频2.2G,10G内存 l  虚拟软 ...

  6. Linq 101 工具和源码

    工具如图: 源码: https://git.oschina.net/yudaming/Linq101

  7. Jena语义Web开发101

    2015/05/28更新 代码在 https://github.com/zhoujiagen/semanticWebTutorialUsingJena 前言 该手册参考和扩展“Hebeler J, F ...

  8. Jena TDB 101 Java API without Assembler

    Update on 2015/05/12 ongoing tutorials site on https://github.com/zhoujiagen/semanticWebTutorialUsin ...

  9. Jena Fuseki 101

    前言 正如其承诺的那样 Expose your triples as a SPARQL end-point accessible over HTTP. Fuseki provides REST-sty ...

随机推荐

  1. 物联网操作系统 - Zephyr

    What is Zephyr? Zephyr Project is a small, scalable real-time operating system for use on resource-c ...

  2. Unity3d shader内置矩阵

    内置矩阵 支持的矩阵(float4x4):UNITY_MATRIX_MVP        当前模型视图投影矩阵UNITY_MATRIX_MV           当前模型视图矩阵UNITY_MATRI ...

  3. 转:关于数据库压缩技术的Survey

    原文来自于:http://outofmemory.cn/mysql/database-compression-tech 昨天给团队内的小伙伴做了一个关于数据库压缩技术的Survey,现将其中可以公开的 ...

  4. [BZOJ 2821] 作诗(Poetize) 【分块】

    题目链接:BZOJ - 2821 题目分析 因为强制在线了,所以无法用莫队..可以使用分块来做. 做法是,将 n 个数分成 n/x 个块,每个块大小为 x .先预处理出 f[i][j] ,表示从第 i ...

  5. Nine Great Books about Information Visualization

    Nine Great Books about Information Visualization Maybe it’s anachronistic to celebrate static, print ...

  6. SharePoint ListTemplateType enumeration

    from microsoft http://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.client.listtempla ...

  7. SaltStack Syndic配置

    参考URL: http://www.ttlsa.com/saltstack/saltstack-syndic-example/ 虽然中心master看不到 minion的key 但是还是可以直接指导m ...

  8. 14.5.2.3 Consistent Nonlocking Reads 一致性非锁定读

    14.5.2.3 Consistent Nonlocking Reads 一致性非锁定读 一致性读意味着 InnoDB 使用多版本来实现一个查询数据库的快照在某个时间点. 查看看到的事务做出的改变被提 ...

  9. bzoj2096

    本来也不打算写这道题的解题报告的,因为比较水直接维护两个单调队列(最大值,最小值)随便弄弄就行了但是我开始疯狂不知道为什么的RE,然后实在没办法找root要了数据测了之后……王苍,根本就没有错啊……我 ...

  10. awk合并文件一例

    群里的朋友求助: $ cat file1a 1 2 3b 2 3 4c 3 4 5 $ cat file2d 你b 好c 吗 合并两个文件,需要实现: a 1 2 3b 2 3 4 好c 3 4 5 ...