コード例 #1
0
 public QueryOptions(IList <QueryFilter> filters     = null,
                     IList <QuerySorter> sorters     = null,
                     IList <QuerySelector> selectors = null,
                     IList <QueryIncluder> includers = null,
                     QueryPagenator pagenator        = null)
 {
     Filters   = filters;
     Sorters   = sorters;
     Selectors = selectors;
     Includers = includers;
     Pagenator = pagenator;
 }
コード例 #2
0
        public virtual IQueryOptions Map(GroupsListOptionsModel optionsModel)
        {
            List <QueryFilter> filters = new List <QueryFilter>();

            if (optionsModel.Name != null)
            {
                filters.Add(new QueryFilterElement("Name", optionsModel.Name, FilterElementOperation.Contains, new QueryFilterAdditionalOptions()
                {
                    IgnoreCase = true
                }));
            }
            if (optionsModel.LanguageId != 0)
            {
                filters.Add(new QueryFilterElement("Language.Id", optionsModel.LanguageId, FilterElementOperation.Equal));
            }
            if (optionsModel.DateFrom != DateTime.MinValue)
            {
                filters.Add(new QueryFilterElement("Date", optionsModel.DateFrom, FilterElementOperation.GreaterThanOrEqual));
            }
            if (optionsModel.DateTo != DateTime.MaxValue)
            {
                filters.Add(new QueryFilterElement("Date", optionsModel.DateTo, FilterElementOperation.LessThanOrEqual));
            }

            List <QuerySorter> sorters   = new List <QuerySorter>();
            SortOrder          sortOrder = Enum.Parse <SortOrder>(optionsModel.SortOrder, true);

            sorters.Add(new QuerySorter(optionsModel.SortProperty, sortOrder));

            List <QueryIncluder> includers = new List <QueryIncluder>();

            includers.Add(new QueryIncluder("Language"));

            int            take      = optionsModel.PageSize;
            int            skip      = optionsModel.PageSize * (Math.Max(optionsModel.PageIndex, 1) - 1);
            QueryPagenator pagenator = new QueryPagenator(take, skip);

            IQueryOptions queryOptions = new QueryOptions(
                filters: filters,
                sorters: sorters,
                includers: includers,
                pagenator: pagenator);

            return(queryOptions);
        }