zoukankan      html  css  js  c++  java
  • Linq 关键字

    from

    var lowNums = from num in numbers
                where num < 5
               
    select num;

    numbers 是数据源,而 num 是范围变量。             请注意,这两个变量都是强类型

    List<Student> students = new List<Student>
            {
               new Student {LastName="Omelchenko", Scores= new List<int> {97, 72, 81, 60}},
               new Student {LastName="O'Donnell", Scores= new List<int> {75, 84, 91, 39}},
               new Student {LastName="Mortensen", Scores= new List<int> {88, 94, 65, 85}},
               new Student {LastName="Garcia", Scores= new List<int> {97, 89, 85, 82}},
               new Student {LastName="Beebe", Scores= new List<int> {35, 72, 91, 70}}
            };       

            // Use a compound from to access the inner sequence within each element.
            // Note the similarity to a nested foreach statement.
            var scoreQuery = from student in students
                             from score in student.Scores
                                where score > 90
                                select new { Last = student.LastName, score };
    where

    条件

    where    子句用在查询表达式中,用于指定将在查询表达式中返回数据源中的哪些元素。            

    它将一个布尔条件(“谓词”)应用于每个源元素(由范围变量引用),并返回满足指定条件的元素。  一个查询表达式可以包含多个 where 子句,一个子句可以包含多个谓词子表达式。

  • 相关阅读:
    less学习笔记(一)
    Angular.js学习笔记(三)
    备份域控制器升级为主域控制器
    MS SQL 2005 无法建立用户实例
    MS sql 无法进行事务日志备份
    安装设置IIS5.1
    问卷设计入门
    windows installer 应用变换时的错误.请验证指定的变换路径是否有
    【HDOJ6225】Little Boxes(Java)
    【HDOJ6222】Heron and His Triangle(Java,二分,递推)
  • 原文地址:https://www.cnblogs.com/handsomer/p/4270422.html
Copyright © 2011-2022 走看看