-
Notifications
You must be signed in to change notification settings - Fork 56
/
Ordering.cs
36 lines (32 loc) · 1.11 KB
/
Ordering.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Linq;
namespace StandardOperators
{
public static class Ordering
{
public static void OrderedQueryExpression()
{
var q = from course in Course.Catalog
orderby course.PublicationDate ascending
select course;
}
public static void WrongMultipleOrderingCriteria()
{
var q = from course in Course.Catalog
orderby course.PublicationDate ascending
orderby course.Duration descending // BAD! Could discard previous order
select course;
}
public static void MultipleOrderingCriteria()
{
var q = from course in Course.Catalog
orderby course.PublicationDate ascending, course.Duration descending
select course;
}
public static void MultipleOrderingCriteriaDirectOperatorUse()
{
var q = Course.Catalog
.OrderBy(course => course.PublicationDate)
.ThenByDescending(course => course.Duration);
}
}
}