public BlogRepository(IBlogContext context, ITagsInString tagsInString, IPropertyMappingService mappingService, IQueryableSorter queryableSorter) { this.context = context; this.tagsInString = tagsInString; this.mappingService = mappingService; this.queryableSorter = queryableSorter; }
public ThenByQueryableSorter( IQueryableSorter <TSource> previousSorter, Expression <Func <TSource, TKey> > keySelector, SortDirection direction) { _previousSorter = previousSorter; _keySelector = keySelector; _direction = direction; }
public QueryableSorterBuilder <T> OrderByDescending <TKey>(Expression <Func <T, TKey> > keySelector) { if (_currentSorter != null) { _currentSorter = new ThenByQueryableSorter <T, TKey>(_currentSorter, keySelector, SortDirection.Descending); } else { _currentSorter = new OrderByQueryableSorter <T, TKey>(keySelector, SortDirection.Descending); } return(this); }
private static IQueryableSorter <T> BuildQueryableSorter(IQueryableSorter <T> previousSorter, string propertyPath, SortDirection direction) { var(keySelector, keyType) = GetPropertyAccessorLambda(propertyPath); if (previousSorter == null) { var sorterType = typeof(OrderByQueryableSorter <,>).MakeGenericType(typeof(T), keyType); return((IQueryableSorter <T>)Activator.CreateInstance(sorterType, keySelector, direction)); } else { var sorterType = typeof(ThenByQueryableSorter <,>).MakeGenericType(typeof(T), keyType); return((IQueryableSorter <T>)Activator.CreateInstance(sorterType, previousSorter, keySelector, direction)); } }
public QueryableSorterBuilder <T> OrderByDescending(string propertyPath) { _currentSorter = BuildQueryableSorter(_currentSorter, propertyPath, SortDirection.Descending); return(this); }