1.from

var scoreQuery = from student in students
from score in student.Scores
where score > 90
select new { Last = student.LastName, score };
2.where
 var queryLowNums3 =
from num in numbers
where num < 5
where num % 2 == 0
select num;

3.select

var studentQuery7 =
from student in app.students
where student.ID > 111
select new { student.First, student.Last };
4.group
var studentQuery =
from student in students
let avg = (int)student.Scores.Average()
group student by (avg == 0 ? 0 : avg / 10) into g
orderby g.Key
select g;
5.into
 var wordGroups1 =
from w in words
group w by w[0] into fruitGroup
where fruitGroup.Count() >= 2
select new { FirstLetter = fruitGroup.Key, Words = fruitGroup.Count() };
6.orderby
  var sortedGroups =
from student in students
orderby student.Last, student.First
group student by student.Last[0] into newGroup
orderby newGroup.Key
select newGroup;
7.join
var innerJoinQuery =
from category in categories
join prod in products on category.ID equals prod.CategoryID
select new { ProductName = prod.Name, Category = category.Name }; //produces flat sequence
var innerGroupJoinQuery =
from category in categories
join prod in products on category.ID equals prod.CategoryID into prodGroup
select new { CategoryName = category.Name, Products = prodGroup };
8.ascending
 IEnumerable<string> sortAscendingQuery =
from vegetable in vegetables
orderby vegetable ascending
select vegetable;
9.descending
IEnumerable<string> sortDescendingQuery =
from vegetable in vegetables
orderby vegetable descending
select vegetable;
10.on
  var innerJoinQuery =
from category in categories
join prod in products on category.ID equals prod.CategoryID
select new { ProductName = prod.Name, Category = category.Name };
11.equals
 var innerJoinQuery =
from category in categories
join prod in products on category.ID equals prod.CategoryID
select new { ProductName = prod.Name, Category = category.Name };
12.by
 var query = from student in students
group student by student.LastName[0];

linq 日常关键字使用的更多相关文章

  1. Linq中关键字的作用及用法

    Linq中关键字的作用及用法 1.All:确定序列中的所有元素是否都满足条件.如果源序列中的每个元素都通过指定谓词中的测试,或者序列为空,则为 true:否则为 false. Demo: 此示例使用 ...

  2. [LINQ]查询关键字

    摘自https://msdn.microsoft.com/zh-cn/library/bb310804.aspx,方便以后翻阅. from子句 查询表达式必须以 from 子句开头.另外,查询表达式还 ...

  3. Linq之关键字基本查询

    子句 说明 from 指定数据源和范围变量(类似于迭代变量). where 根据一个或多个由逻辑"与"和逻辑"或"运算符(&& 或 ||)分隔的 ...

  4. 日常关键字:定时关机、该任务映像已损坏或已篡改.(0x80041321)、ChaZD生词同步扇贝

    我在床上用chinanet网络慢得简直令人发指,12B/S.是的你没有看错,这是我最常看到的网速.但是我最近发现电脑联网开出一个WiFi,在床上用手机上网时,网速会一点提升,可达到1KB/S(⊙﹏⊙) ...

  5. LINQ日常使用记录

    1.公司一位美女程序媛写的 2.技术总监提供(来自互联网) var query = from f in db.TField join fw in db.TFieldWel on f.emp_no eq ...

  6. 通过orderby关键字,LINQ可以实现升序和降序排序。LINQ还支持次要排序。

    通过orderby关键字,LINQ可以实现升序和降序排序.LINQ还支持次要排序. LINQ默认的排序是升序排序,如果你想使用降序排序,就要使用descending关键字. static void M ...

  7. 对于Linq关键字和await,async异步关键字的扩展使用

    最近在看neuecc大佬写的一些库:https://neuecc.medium.com/,其中对await,async以及linq一些关键字实现了自定义化使用, 使其不需要引用对应命名空间,不需要多线 ...

  8. Linq的查询操作符

    Linq有表达式语法和调用方法的语法.两者是可以结合使用,通常情况下也都是结合使用.表达式语法看上去比较清晰而调用方法的语法实现的功能更多,在此文章中介绍的是表达式语法.方法语法可以看System.L ...

  9. .Net 如何实现 LINQ~

    本文内容 引入 实现 LINQ 的两个前提 扩展方法 λ 表达式 LINQ 参考资料 本文说明 LINQ 是如何实现的,知道这点,才能更好地使用它~ 如果你刚接触 LINQ,那么可能不会那么快就理解. ...

随机推荐

  1. Java再学习——栈(stack)和堆(heap)

    一.内存分配的策略 按照编译原理的观点,程序运行时的内存分配有三种策略,分别是静态的,栈式的,和堆式的. 静态存储分配是指在编译时就能确定每个数据目标在运行时刻的存储空间需求,因而在编译时就可以给他们 ...

  2. js和jquery的DOM事件大全

  3. C#使用Monitor类、Lock和Mutex类进行多线程同步

    在多线程中,为了使数据保持一致性必须要对数据或是访问数据的函数加锁,在数据库中这是很常见的,但是在程序中由于大部分都是单线程的程序,所以没有加锁的必要,但是在多线程中,为了保持数据的同步,一定要加锁, ...

  4. Linux 下configure 参数配置与软件的安装与卸载

    Linux环境下的软件安装,并不是一件容易的事情:如果通过源代码编译后在安装,当然事情就更为复杂一些:现在安装各种软件的教程都非常普遍:但万变不离其中,对基础知识的扎实掌握,安装各种软件的问题就迎刃而 ...

  5. IOS UItableView 滚动到底 触发事件

    开发过程中,在使用UItableView 总会遇到加载更多的问题,到底是手势响应瀑布流的方法好? 还是添加一个底端cell点击触发加载更多好?我也想有自己的判断.但是我们老板总说了算,没办法,谁叫我给 ...

  6. CNZZ每天百亿条日志写入,SLS+ODPS轻松拆招

    如果你是一个站长,想要提交一个查询,从一亿多条日志中找出从湖南省发出.使用ISP电信.通过百度搜索跳转到达的访问日志.该怎么做? 别急,在接收到您的查询条件后,CNZZ可以快速通过SLS(简单日志服务 ...

  7. 递归删除指定目录下的 .git 文件

    转载自:http://my.oschina.net/armsky/blog/34447 find . -name .git | xargs rm -fr 其中对 xargs 的介绍,可以参照以下内容: ...

  8. zoj 3742 Delivery 好题

    Delivery 题目还是自己看吧 - -! 看似图论,实际上是一个考察思维以及数据结构的题. 我们对于先前和向后的边分别进行统计. 对询问离线. 小边按照左端点从大到小排序. 1.对于向后的边,询问 ...

  9. 每天一道LeetCode--409 .Longest Palindrome

    Given a string which consists of lowercase or uppercase letters, find the length of the longest pali ...

  10. 【学习笔记】【C语言】变量类型

    根据变量的作用域,可以分为: 1.局部变量: 1> 定义:在函数(代码块)内部定义的变量(包括函数的形参) 2> 作用域:从定义变量的那一行开始,一直到代码块结束 3> 生命周期:从 ...