Exemplo n.º 1
0
        public static EntitySort Parse(string sortString)
        {
            if (string.IsNullOrEmpty(sortString))
            {
                return(null);
            }

            var parts = sortString.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length == 0)
            {
                return(null);
            }

            var sort = new EntitySort();

            sort.Name = parts[0]?.Trim();

            if (parts.Length >= 2)
            {
                sort.Direction = parts[1]?.Trim();
            }

            return(sort);
        }
Exemplo n.º 2
0
        public EntityQuery(IQuery <TEntity> query, int page, int pageSize, string sort)
        {
            Query    = query;
            Page     = page;
            PageSize = pageSize;

            var entitySort = EntitySort.Parse(sort);

            if (entitySort == null)
            {
                return;
            }

            Sort = new[] { entitySort };
        }