File tree 2 files changed +49
-0
lines changed
2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ namespace Nest
2
+ {
3
+ using System ;
4
+ using System . Collections . Generic ;
5
+
6
+ /// <summary>
7
+ /// Provides MultiSort extensions that allow easy sorting across multiple fields
8
+ /// </summary>
9
+ public static class MultiSortExtensions
10
+ {
11
+ public static SearchDescriptor < T > MultiSort < T > (
12
+ this SearchDescriptor < T > instance ,
13
+ params Func < SortFieldDescriptor < T > , IFieldSort > [ ] sorts ) where T : class
14
+ {
15
+ foreach ( var sort in sorts )
16
+ {
17
+ instance . Sort ( sort ) ;
18
+ }
19
+
20
+ return instance ;
21
+ }
22
+
23
+ public static SearchDescriptor < T > MultiSort < T > (
24
+ this SearchDescriptor < T > instance ,
25
+ IEnumerable < Func < SortFieldDescriptor < T > , IFieldSort > > sorts ) where T : class
26
+ {
27
+ foreach ( var sort in sorts )
28
+ {
29
+ instance . Sort ( sort ) ;
30
+ }
31
+
32
+ return instance ;
33
+ }
34
+
35
+ public static SearchDescriptor < T > MultiSort < T > (
36
+ this SearchDescriptor < T > instance ,
37
+ IEnumerable < SortFieldDescriptor < T > > sorts ) where T : class
38
+ {
39
+ foreach ( var sort in sorts )
40
+ {
41
+ var copy = sort ;
42
+ instance . Sort ( s => copy ) ;
43
+ }
44
+
45
+ return instance ;
46
+ }
47
+ }
48
+ }
Original file line number Diff line number Diff line change 72
72
<Compile Include =" ConvenienceExtensions\DeleteManyExtensions.cs" />
73
73
<Compile Include =" ConvenienceExtensions\GetManyExtensions.cs" />
74
74
<Compile Include =" ConvenienceExtensions\CreateIndexExtensions.cs" />
75
+ <Compile Include =" ConvenienceExtensions\MultiSortExtensions.cs" />
75
76
<Compile Include =" ConvenienceExtensions\OpenCloseIndexExtensions.cs" />
76
77
<Compile Include =" ConvenienceExtensions\ExistsExtensions.cs" />
77
78
<Compile Include =" ConvenienceExtensions\ScrollExtensions.cs" />
You can’t perform that action at this time.
0 commit comments