Esempio n. 1
0
        public SearchyRequest(string queryString) : this()
        {
            var queryDictionary = QueryStringParser.Parse(queryString);

            if (queryDictionary.TryGetValue(FilterName, out var filters))
            {
                var cond = new SearchyCondition();
                Conditions.Add(cond);
                foreach (var str in filters)
                {
                    cond.Filters.Add(new SearchyFilter(str));
                }
            }

            if (queryDictionary.TryGetValue(SortName, out var sorts))
            {
                foreach (var str in sorts)
                {
                    Sorts.Add(new SearchySort(str));
                }
            }

            if (queryDictionary.TryGetValue(PageSizeName, out var sizes) &&
                sizes.Any() &&
                int.TryParse(sizes.First(), out var pageSize))
            {
                PageSize = pageSize;
            }

            if (queryDictionary.TryGetValue(PageIndexName, out var pages) &&
                pages.Any() &&
                int.TryParse(pages.First(), out var pageIndex))
            {
                PageIndex = pageIndex;
            }

            if (queryDictionary.TryGetValue(CountRowsName, out var counts) &&
                counts.Any() &&
                bool.TryParse(counts.First(), out var countRows))
            {
                CountRows = countRows;
            }

            if (queryDictionary.TryGetValue(SearchPhraseName, out var searches) &&
                searches.Any())
            {
                SearchPhrase = searches.First();
            }


            if (queryDictionary.TryGetValue(FormatName, out var formats) &&
                formats.Any() &&
                byte.TryParse(formats.First(), out var format))
            {
                Format = format;
            }
        }
Esempio n. 2
0
        public SearchyRequest(string[] filters, string[] sorts = null, int pageSize = 0, int pageIndex = 0, bool countRows = false) : this()
        {
            if (filters != null)
            {
                var cond = new SearchyCondition();
                Conditions.Add(cond);
                foreach (var str in filters)
                {
                    cond.Filters.Add(new SearchyFilter(str));
                }
            }

            if (sorts != null)
            {
                foreach (var str in sorts)
                {
                    Sorts.Add(new SearchySort(str));
                }
            }

            PageSize  = pageSize;
            PageIndex = pageIndex;
            CountRows = countRows;
        }
Esempio n. 3
0
 public SearchyRequest(SearchyCondition condition) : this()
 {
     Conditions.Add(condition);
 }
Esempio n. 4
0
 public SearchyQuery(SearchyCondition condition) => Conditions.Add(condition);