コード例 #1
0
 public BlogRepository(IBlogContext context, ITagsInString tagsInString,
                       IPropertyMappingService mappingService, IQueryableSorter queryableSorter)
 {
     this.context         = context;
     this.tagsInString    = tagsInString;
     this.mappingService  = mappingService;
     this.queryableSorter = queryableSorter;
 }
コード例 #2
0
 public ThenByQueryableSorter(
     IQueryableSorter <TSource> previousSorter,
     Expression <Func <TSource, TKey> > keySelector,
     SortDirection direction)
 {
     _previousSorter = previousSorter;
     _keySelector    = keySelector;
     _direction      = direction;
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
 public QueryableSorterBuilder <T> OrderByDescending(string propertyPath)
 {
     _currentSorter = BuildQueryableSorter(_currentSorter, propertyPath, SortDirection.Descending);
     return(this);
 }