예제 #1
0
        private static SortDescriptor <VacancyElasticModel> Sort(VacancySortModel sortModel)
        {
            var sort = new SortDescriptor <VacancyElasticModel>();

            if (sortModel == null)
            {
                return(sort.Descending(p => p.Id));
            }
            if (sortModel.StartDate != null)
            {
                sort = sortModel.StartDate == true
                    ? sort.Ascending(p => p.StartDate)
                    : sort.Descending(p => p.StartDate);
            }
            else if (sortModel.RequestDate != null)
            {
                sort = sortModel.RequestDate == true
                    ? sort.Ascending(p => p.Id)
                    : sort.Descending(p => p.Id);
            }
            else if (sortModel.CloseDate != null)
            {
                sort = sortModel.CloseDate == true
                    ? sort.Ascending(p => p.CloseDate)
                    : sort.Descending(p => p.CloseDate);
            }
            else
            {
                sort = sort.Descending(p => p.Id);
            }
            return(sort);
        }
        private static SortDescriptor <CandidateElasticModel> Sort(CandidateSortModel sortModel)
        {
            var sort = new SortDescriptor <CandidateElasticModel>();

            if (sortModel == null)
            {
                return(sort.Descending(p => p.Id));
            }

            if (sortModel.LastContactDate != null)
            {
                sort = sortModel.LastContactDate == true
                    ? sort.Ascending(p => p.LastContactDate)
                    : sort.Descending(p => p.LastContactDate);
            }
            else if (sortModel.CreationDate != null)
            {
                sort = sortModel.CreationDate == true
                    ? sort.Ascending(p => p.Id)
                    : sort.Descending(p => p.Id);
            }
            else if (sortModel.RemindDate != null)
            {
                sort = sortModel.RemindDate == true
                    ? sort.Ascending(p => p.RemindDate)
                    : sort.Descending(p => p.RemindDate);
            }
            else
            {
                sort = sort.Descending(p => p.Id);
            }
            return(sort);
        }
예제 #3
0
        protected static IPromise <IList <ISort> > GetSortDescriptor <T>(SortDescriptor <T> me, Dictionary <string, SortDirectionEnum> dictionary) where T : class
        {
            if (dictionary != null)
            {
                foreach (var item in dictionary)
                {
                    var prop = typeof(T).GetProperty(item.Key, BindingFlags.IgnoreCase | BindingFlags.FlattenHierarchy | BindingFlags.Instance |
                                                     BindingFlags.Public);

                    var fieldNameExp = Expression.Property(Expression.Parameter(typeof(T)), prop);
                    var suffixMethod = typeof(SuffixExtensions).GetMethod("Suffix", BindingFlags.Public | BindingFlags.Static);
                    var callmethod   = Expression.Call(suffixMethod, fieldNameExp, Expression.Constant(Constants.ELK_KEYWORD_SUFFIX));
                    var lambda       = Expression.Lambda(callmethod, Expression.Parameter(typeof(T)));

                    if (item.Value == SortDirectionEnum.Asc)
                    {
                        me.Ascending(lambda);
                    }
                    else
                    {
                        me.Descending(lambda);
                    }
                }

                return(me);
            }

            return(default);
예제 #4
0
        private SortDescriptor <TEntity> GetSortDescriptor(string sortField, OrderBy sortOrder)
        {
            SortDescriptor <TEntity> sortDesciptor = new SortDescriptor <TEntity>();

            if (!string.IsNullOrEmpty(sortField))
            {
                sortDesciptor = sortOrder == OrderBy.Ascending ? sortDesciptor.Ascending(sortField)
                                                   : sortDesciptor.Descending(sortField);
            }
            return(sortDesciptor);
        }
예제 #5
0
        private static SortDescriptor <T> Sort <T>(SortDescriptor <T> ss, string sortingType, string selectedSortingField)
            where T : class
        {
            switch (sortingType)
            {
            case "desc":
                ss.Descending(selectedSortingField);
                break;

            case "asc":
                ss.Ascending(selectedSortingField);
                break;

            default:
                ss = BookRepositorySettings.DEFAULT_SORTING.Equals(DefaultSorting.Descending)
                        ? ss.Descending(selectedSortingField)
                        : ss.Ascending(selectedSortingField);
                break;
            }

            return(ss);
        }
예제 #6
0
        private SortDescriptor <ProductListV2> BuildSort(SearchParamModel model)
        {
            var sort = new SortDescriptor <ProductListV2>();

            sort = sort.Descending(x => x.InventoryStatus);
            if (model.order_rule == "1")
            {
                sort = sort.Descending(x => x.SalesVolume);
            }
            else if (model.order_rule == "2")
            {
                sort = sort.Ascending(x => x.SalesPrice);
            }
            else
            {
                sort = sort.Descending(x => x.SalesPrice);
            }
            return(sort);
        }
예제 #7
0
        private SortDescriptor <ProductListV2> BuildSort(SearchParamModel model)
        {
            var sort = new SortDescriptor <ProductListV2>();

            sort = sort.Descending(x => x.InventoryStatus);
            if (model.order_rule == "1")
            {
                sort = sort.Descending(x => x.SalesVolume);
            }
            else if (model.order_rule == "2")
            {
                sort = sort.Ascending(x => x.SalesPrice);
            }
            else
            {
                sort = sort.Descending(x => x.SalesPrice);
            }

            //更具坐标排序
            sort = sort.GeoDistance(x => x.Field(f => f.IsGroup).PinTo(new GeoLocation(52.310551, 4.404954)).Ascending());

            return(sort);
        }
예제 #8
0
 public SortDescriptor <QueryablePerson> GetSortDescriptor(SortDescriptor <QueryablePerson> descriptor)
 {
     return(descriptor
            .Ascending(f => f.Surname)
            .Ascending(f => f.Firstname));
 }
예제 #9
0
 public SortDescriptor <QueryableAsset> GetSortDescriptor(SortDescriptor <QueryableAsset> descriptor)
 {
     return(descriptor
            .Ascending(f => f.Id.Suffix("keyword")));
 }
예제 #10
0
 public void SortAsc(Expression <Func <TEntity, object> > expression)
 {
     sort.Ascending(expression);
 }