zoukankan      html  css  js  c++  java
  • Linq学习from let where子句

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    /*from let where子句
     * 1、from 后面接的是查询主体,可以有任何数量个,指定了额外的数据集合并引入了要在之后运算的迭代变量
     * 2、let子句接受一个表达式的运算并且把它赋值给一个需要在其他运算中使用的标识符。
     * 3、where子句根据之后的运算来除去不符合指定条件的项
     */
    namespace from_let_where
    {
        class Program
        {
            static void Main(string[] args)
            {
                var GroupA = new[] { 3, 4, 5, 6 };
                var GroupB = new[] { 4, 5,6,7};
                var someInt1 = from int a in GroupA
                              from int b in GroupB
                              where a>4&&b<=8
                              select new { a, b, sum=a+b};//匿名类型变量
                foreach (var a in someInt1)
                    Console.WriteLine(a);
                var someInt2 = from int a in GroupA
                              from int b in GroupB
                              let sum = a + b
                              where sum >= 11
                              where a == 4
                              select new { a, b, sum };
                foreach (var a in someInt2)
                    Console.WriteLine(a);
                Console.ReadKey();
            }
        }
    }
  • 相关阅读:
    Windows下MySQL数据库备份脚本(二)
    pt-query-digest用法
    pt-online-schema-change 实例
    pt-kill使用
    pt-find 使用实例
    利用pt-deadlock-logger监控死锁
    pt-fifo-split使用
    bash{} 方法总结
    python psutil 模块
    Zabbix的安装与部署---问题处理(php65.6.28 mysqli 报错误 处理)
  • 原文地址:https://www.cnblogs.com/sulong/p/4808096.html
Copyright © 2011-2022 走看看