当前位置:首页 > LINQ常用查询操作符及其对应查询语法

LINQ常用查询操作符及其对应查询语法

点击次数:2113  更新日期:2013-03-29

介绍

Select -Select选择;延迟

Where -Where查询;延迟

OrderBy -按指定表达式对集合正序排序;延迟

OrderByDescending -按指定表达式对集合倒序排序;延迟

GroupBy -分组;延迟

Join -Join查询;延迟

GroupJoin -分组Join查询;延迟

以上查询操作符所对应的查询语法

示例
View Code

1 Summary.aspx.cs
2
3 using System;
4 using System.Data;
5 using System.Configuration;
6 using System.Collections;
7 using System.Linq;
8 using System.Web;
9 using System.Web.Security;
10 using System.Web.UI;
11 using System.Web.UI.WebControls;
12 using System.Web.UI.WebControls.WebParts;
13 using System.Web.UI.HtmlControls;
14 using System.Xml.Linq;
15
16 using System.Collections.Generic;
17 using DAL;
18
19 public partial class LINQ_Summary : System.Web.UI.Page
20 {
21     NorthwindDataContext _ctx = new NorthwindDataContext();
22     string[] _ary = null;
23
24     protected void Page_Load(object sender, EventArgs e)
25     {
26         _ary = new string[] { asp.net, csharp, xhtml, css, javascript,
27             wcf, wpf, silverlight, linq, wf,
28             sqlserver, asp.net ajax, ssis, ssas, ssrs };
29
30         // Select - Select选择;延迟
31         Summary_Select();
32
33         // Where - Where查询;延迟
34         Summary_Where();
35
36         // OrderBy - 按指定表达式对集合正序排序;延迟
37         // OrderByDescending - 按指定表达式对集合倒序排序;延迟
38         Summary_OrderBy_OrderByDescending();
39
40         // GroupBy - 分组;延迟
41         Summary_GroupBy();
42
43         // Join - Join查询;延迟
44         Summary_Join();
45
46         // GroupJoin - 分组Join查询;延迟
47         Summary_GroupJoin();
48     }
49 }







Select - Select选择;延迟
View Code

1     /// summary
2     /// Select - Select选择;延迟
3     /// /summary
4     void Summary_Select()