Query Operator Overview
The sections that follow describe each of the LINQ query operators, as summarized in Table 1-1.
Table 1-1. LINQ query operators
Category | Operators |
---|---|
Filtering | |
Projecting | |
Joining | |
Ordering | |
Grouping | |
Set | |
Conversion import) | |
Conversion export) | |
Element | |
Aggregation | |
Quantifiers | |
Generation | |
The examples assume that a names
array is defined as follows:
string[] names = { "Tom","Dick","Harry","Mary","Jay" };
Examples that use LINQ to SQL assume a typed DataContext
variable called dataContext
:
var dataContext = new DemoDataContext(); ... public class DemoDataContext : DataContext { public DemoDataContext (string cxString) : base (cxString) { } public Table<Customer> Customers { get { return GetTable<Customer>(); } } public Table<Purchase> Purchases { get { return GetTable<Purchase>(); } } } [Table] public class Customer { [Column(IsPrimaryKey=true)]public int ID;
[Column]public stringName;
[Association(OtherKey="CustomerID")]public EntitySet<Purchase>Purchases
= new EntitySet<Purchase>(); } ...
Get LINQ Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.