1,Concat (connecting different sets does not automatically filter the same item. Will delay calculation)
var q = (from c in db.Customers select c.Phone ).Concat( from e in db.Employees select e.HomePhone); var q = (from c in db.Customers select new { Name = c.CustomerName, Phone = c.Phone }).Concat( from e in db.Employees select new { Name = e.EmployeeName, Phone = e.HomePhone });
2,Union (merge to automatically filter identical items. Will delay calculation)
var q = (from c in db.Customers select c.Country).Union( from e in db.Employees select e.Country);
3,Intersect (intersection. Will delay calculation)
var q = (from c in db.Customers select c.Country).Intersect( from e in db.Employees select e.Country);
4,T (difference, a-B. Exclude A from B from a set. Will delay calculation)
var q = (from c in db.Customers select c.Country).Except( from e in db.Employees select e.Country);
5,Top and bottom (fetch a specified amount of data. Will delay calculation)
6,Take (obtain the first n data of the set. Will delay calculation)
var q = (from e in db.Employees orderby e.HireDate selct e).Take(5);
7,Skip (skip the first n data records of the set. Will delay calculation)
var q = (from p in db.Products orderby p.UnitPrice descending select p).Skip(10);
Select All products other than the 10 most expensive products
8,Takewhile (it is not obtained until a condition is invalid. Will delay calculation)
That is, use its conditions to determine the elements in the source sequence in sequence, and return the elements that meet the judgment conditions. The judgment operation ends at the end of the returned false or source sequence.
9,Skipwhile (same as above)
10,Paging)
var q = (from c in db.Customers orderby c.CustomerName select c).Skip(50).Take(10);
11,Like
var q = from c in db.Customers where SqlMethods.Like(c.CustomerID, "C%") select c;
Query Consumers whose consumer IDs do not have the "axoxt" format:
var q = from c in db.Customers where !SqlMethods.Like(c.CustomerID, "A_O_T") select c;DateDiffDay
Compare two time variables. There are: datediffday, datediffhour, datediffmillisecond, datediffminute, datediffmonth, datediffsecond, datediffyear:
var q = from o in db.Orders where SqlMethod.DateDiffDay(o.OrderDate, o.ShippedDate) < 10 select o;
Query all orders delivered within 10 days after the order is created
12,Compiled query (pre-compiled query)
NorthwindDataContext db = new NorthwindDataContext(); var fn = CompiledQuery.Compile( (NorthwindDataContext db2, string city) => from c in db2.Customers where c.City == city select c); var londonCusts = fn(db, "London"); var seaCusts = fn(db, "Seattle");