//http://ravendb.net/docs/faq/lucene-queries-examples?version=2 //https://github.com/ravendb/ravendb/commit/721c50ea51ff7721928cca76de957e9f7d9e3786 public static IDocumentQuery <T> AddContentManagementQueryTerms <T>(this IDocumentQuery <T> documentQuery, IContentPublicationStateManager contentPublicationStateManager, IContentPublicationDateTimeManager contentPublicationDateTimeManager) { if (contentPublicationStateManager.ContentPublicationStateIsDraft()) { return(documentQuery.OrderBy("CreationDate").AndAlso().WhereEquals("PublicationCreationDate", null)); } var dateTime = contentPublicationDateTimeManager.GetContentPublicationDateTime().Value; return(documentQuery.OrderByDescending("CreationDate").AndAlso() .Not.WhereEquals("PublicationCreationDate", null) .AndAlso().WhereGreaterThan("PublicationEndingDate", dateTime) .AndAlso().WhereLessThanOrEqual("PublicationStartingDate", dateTime)); }
public static IDocumentQuery <T> OrderByMultipleItemsWithCommonOrder <T>(this IDocumentQuery <T> query, OrderDirection orderDirection, params string[] propertySelectors) { if (propertySelectors == null || !propertySelectors.Any()) { return(query); } if (propertySelectors.Any(p => string.IsNullOrWhiteSpace(p))) { throw new ArgumentException("One or more property selectors is(are) invalid", nameof(propertySelectors)); } query = orderDirection == OrderDirection.Asc ? query.OrderBy(propertySelectors) : query.OrderByDescending(propertySelectors); return(query); }