private static void AddIndexColumn( string indexName, IndexOptions indexOptions, int column, PrimitivePropertyConfiguration propertyConfiguration) { var indexAttribute = new IndexAttribute(indexName, column) { IsClustered = indexOptions.HasFlag(IndexOptions.Clustered), IsUnique = indexOptions.HasFlag(IndexOptions.Unique) }; var annotation = GetIndexAnnotation(propertyConfiguration); if (annotation != null) { var attributes = annotation.Indexes.ToList(); attributes.Add(indexAttribute); annotation = new IndexAnnotation(attributes); } else { annotation = new IndexAnnotation(indexAttribute); } propertyConfiguration.HasColumnAnnotation(IndexAnnotation.AnnotationName, annotation); }
private void PutIndex(IndexOptions options) { if (options.HasFlag(IndexOptions.Search)) { DocumentStore.ExecuteIndex(new UserSearchIndex()); } if (options.HasFlag(IndexOptions.Sort)) { DocumentStore.ExecuteIndex(new UserSortIndex()); } }
private void SetIndicesAndAssertWeCanRetrieveUsersOrderedByName(IndexOptions indexOptions, User[] users) { PutIndex(indexOptions); StoreItems(users); using (var s = DocumentStore.OpenSession()) { IRavenQueryable <User> query; if (indexOptions.HasFlag(IndexOptions.Sort)) { query = s.Query <User, UserSortIndex>(); // use it if specified } else { query = s.Query <User>(); } query = query.OrderBy(dto => dto.Name); AssertRetrievedOrdered(query); } }
private void SetIndicesAndAssertWeCanRetrieveUsersOrderedByName(IndexOptions indexOptions, User[] users) { PutIndex(indexOptions); StoreItems(users); using (var s = DocumentStore.OpenSession()) { IRavenQueryable<User> query; if(indexOptions.HasFlag(IndexOptions.Sort)) query = s.Query<User, UserSortIndex>(); // use it if specified else query = s.Query<User>(); query = query.OrderBy(dto => dto.Name); AssertRetrievedOrdered(query); } }
private void PutIndex(IndexOptions options) { if (options.HasFlag(IndexOptions.Search)) DocumentStore.ExecuteIndex(new UserSearchIndex()); if (options.HasFlag(IndexOptions.Sort)) DocumentStore.ExecuteIndex(new UserSortIndex()); }