LINQ - Set Operators
Distinct去掉重复 Union(合并) Intersect(交集) Except叉集 Concat(连接)
LINQ - Restriction Operators
<> &#61;&#61; && ||
LINQ - Query Execution
i&#43;&#43;
LINQ - Quantifiers
Any集合中是否有元素满足某一条件 All集合中所有元素是否都满足某一条件
Contains集合中是否包含有某一元素 Exists是否存在
LINQ - Projection Operators
dt.AsEnumerable()可用于linq方法 n.Field
LINQ - Partitioning Operators
Take(3)前3个 Skip(4) 跳过前4个 TakeWhile(n &#61;> n <6)不要后面6个 SkipWhile&#xff08;&#xff09;指定条件跳过
LINQ - Ordering Operators
orderby word orderby word.Length orderby d descending倒叙 words.OrderBy&#xff08;&#xff09;
words.OrderByDescending&#xff08;&#xff09; orderby digit.Length, digit
words.OrderBy(a &#61;> a.Length).ThenBy(a &#61;> a, new CaseInsensitiveComparer());
words.OrderBy(a &#61;> a.Length).ThenByDescending(a &#61;> a, new CaseInsensitiveComparer());
.Reverse()翻转
public class CaseInsensitiveComparer : IComparer
{
public int Compare(string x, string y)
{
return string.Compare(x, y, StringComparison.OrdinalIgnoreCase);
}
}
LINQ - Miscellaneous Operators
Concat 连接 wordsA.SequenceEqual(wordsB);比较 是否相同
LINQ - Join Operators
join cust in customers on new { sup.City, sup.Country } equals new { cust.City, cust.Country
} into cs
LINQ - Generation Operators
var numbers &#61;from n in Enumerable.Range(100, 50) 生成指定范围的整数数列
var numbers &#61; Enumerable.Repeat(7, 10); 生成重复的序列号
LINQ - Element Operators
.First(); First(s &#61;> s[0] &#61;&#61; &#39;o&#39;); FirstOrDefault();
FirstOrDefault(p &#61;> p.ProductID &#61;&#61; 789); ElementAt(1); 返回索引指定
LINQ - Custom Sequence Operators
public static IEnumerable Combine(this IEnumerable
IEnumerable
{
using (IEnumerator
second.GetEnumerator())
{
while (e1.MoveNext() && e2.MoveNext())
{
yield return func(e1.Current, e2.Current);
}
}
}
var numbersA &#61; testDS.Tables["NumbersA"].AsEnumerable();
var numbersB &#61; testDS.Tables["NumbersB"].AsEnumerable();
int dotProduct &#61; numbersA.Combine(numbersB, (a, b) &#61;> a.Field
* b.Field
LINQ - Conversion Operators
ToArray(); ToList(); ToDictionary(sr &#61;> sr.Name);
numbers.OfType
LINQ - Aggregate Operators
Max Min SUN 要看的
LINQ - Grouping Operators