refactoring.
This commit is contained in:
		
							parent
							
								
									cc6fc09d79
								
							
						
					
					
						commit
						b5331a7837
					
				| @ -1,74 +1,12 @@ | ||||
| using PoweredSoft.DynamicLinq.Helpers; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| 
 | ||||
| namespace PoweredSoft.DynamicLinq.Fluent | ||||
| { | ||||
|     public class SortBuilderBase | ||||
|     { | ||||
|         public List<OrderByPart> Sorts { get; protected set; } = new List<OrderByPart>(); | ||||
| 
 | ||||
|         public virtual SortBuilderBase Sort(string path, QuerySortDirection sortDirection, bool appendSort) | ||||
|         { | ||||
|             Sorts.Add(new OrderByPart | ||||
|             { | ||||
|                 Path = path, | ||||
|                 sortDirection = sortDirection, | ||||
|                 AppendSort = appendSort | ||||
|             }); | ||||
|             return this; | ||||
|         } | ||||
| 
 | ||||
|         public virtual SortBuilderBase OrderBy(string path) | ||||
|         { | ||||
|             Sorts.Clear(); | ||||
|             Sorts.Add(new OrderByPart | ||||
|             { | ||||
|                 Path = path, | ||||
|                 sortDirection = QuerySortDirection.Ascending, | ||||
|                 AppendSort = false | ||||
|             }); | ||||
|             return this; | ||||
|         } | ||||
| 
 | ||||
|         public virtual SortBuilderBase OrderByDescending(string path) | ||||
|         { | ||||
|             Sorts.Clear(); | ||||
|             Sorts.Add(new OrderByPart | ||||
|             { | ||||
|                 Path = path, | ||||
|                 sortDirection = QuerySortDirection.Descending, | ||||
|                 AppendSort = false | ||||
|             }); | ||||
|             return this; | ||||
|         } | ||||
| 
 | ||||
|         public virtual SortBuilderBase ThenBy(string path) | ||||
|         { | ||||
|             Sorts.Add(new OrderByPart | ||||
|             { | ||||
|                 Path = path, | ||||
|                 sortDirection = QuerySortDirection.Ascending, | ||||
|                 AppendSort = true | ||||
|             }); | ||||
|             return this; | ||||
|         } | ||||
| 
 | ||||
|         public virtual SortBuilderBase ThenByDescending(string path) | ||||
|         { | ||||
|             Sorts.Add(new OrderByPart | ||||
|             { | ||||
|                 Path = path, | ||||
|                 sortDirection = QuerySortDirection.Descending, | ||||
|                 AppendSort = true | ||||
|             }); | ||||
|             return this; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public class OrderByBuilder<T> : SortBuilderBase | ||||
|     public class OrderByBuilder<T> : OrderByBuilderBase | ||||
|     { | ||||
|         public IQueryable<T> Query { get; } | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										66
									
								
								PoweredSoft.DynamicLinq/Fluent/OrderBy/OrderByBuilderBase.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								PoweredSoft.DynamicLinq/Fluent/OrderBy/OrderByBuilderBase.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,66 @@ | ||||
| using System.Collections.Generic; | ||||
| 
 | ||||
| namespace PoweredSoft.DynamicLinq.Fluent | ||||
| { | ||||
|     public class OrderByBuilderBase | ||||
|     { | ||||
|         public List<OrderByPart> Sorts { get; protected set; } = new List<OrderByPart>(); | ||||
| 
 | ||||
|         public virtual OrderByBuilderBase Sort(string path, QuerySortDirection sortDirection, bool appendSort) | ||||
|         { | ||||
|             Sorts.Add(new OrderByPart | ||||
|             { | ||||
|                 Path = path, | ||||
|                 sortDirection = sortDirection, | ||||
|                 AppendSort = appendSort | ||||
|             }); | ||||
|             return this; | ||||
|         } | ||||
| 
 | ||||
|         public virtual OrderByBuilderBase OrderBy(string path) | ||||
|         { | ||||
|             Sorts.Clear(); | ||||
|             Sorts.Add(new OrderByPart | ||||
|             { | ||||
|                 Path = path, | ||||
|                 sortDirection = QuerySortDirection.Ascending, | ||||
|                 AppendSort = false | ||||
|             }); | ||||
|             return this; | ||||
|         } | ||||
| 
 | ||||
|         public virtual OrderByBuilderBase OrderByDescending(string path) | ||||
|         { | ||||
|             Sorts.Clear(); | ||||
|             Sorts.Add(new OrderByPart | ||||
|             { | ||||
|                 Path = path, | ||||
|                 sortDirection = QuerySortDirection.Descending, | ||||
|                 AppendSort = false | ||||
|             }); | ||||
|             return this; | ||||
|         } | ||||
| 
 | ||||
|         public virtual OrderByBuilderBase ThenBy(string path) | ||||
|         { | ||||
|             Sorts.Add(new OrderByPart | ||||
|             { | ||||
|                 Path = path, | ||||
|                 sortDirection = QuerySortDirection.Ascending, | ||||
|                 AppendSort = true | ||||
|             }); | ||||
|             return this; | ||||
|         } | ||||
| 
 | ||||
|         public virtual OrderByBuilderBase ThenByDescending(string path) | ||||
|         { | ||||
|             Sorts.Add(new OrderByPart | ||||
|             { | ||||
|                 Path = path, | ||||
|                 sortDirection = QuerySortDirection.Descending, | ||||
|                 AppendSort = true | ||||
|             }); | ||||
|             return this; | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user