public Task <ContentItem[]> GetContentItems(ContentItemQuery query) { var q = _liteRepository.Query <ContentItem>(); if (!string.IsNullOrEmpty(query.AppId)) { q = q.Where(ci => ci.AppId == query.AppId); } if (!string.IsNullOrEmpty(query.Id)) { q = q.Where(ci => ci.Id == query.Id); } if (!string.IsNullOrEmpty(query.CollectionId)) { q = q.Where(ci => ci.CollectionId == query.CollectionId); } if (!string.IsNullOrEmpty(query.ContentKey)) { q = q.Where(ci => ci.ContentKey == query.ContentKey); } if (!string.IsNullOrEmpty(query.ContentKeyStartsWith)) { q = q.Where(ci => ci.ContentKey.StartsWith(query.ContentKeyStartsWith)); } switch (query.OrderBy) { case ContentItemQuery.ContentItemsOrderBy.LastModifiedAtDescending: q = q.OrderByDescending(ci => ci.LastModifiedAt); break; case ContentItemQuery.ContentItemsOrderBy.ContentKey: q = q.OrderBy(ci => ci.ContentKey); break; } ILiteQueryableResult <ContentItem> result = q; if (query.Offset.HasValue) { result = result.Skip(query.Offset.Value); } if (query.First.HasValue) { result = result.Limit(query.First.Value); } return(Task.FromResult(result.ToArray())); }
public IDataQuery <T> Skip(int offset) => new LiteDataQueryResult <T>(_queryable, _result.Skip(offset));