コード例 #1
0
        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);
        }
コード例 #2
0
 private void PutIndex(IndexOptions options)
 {
     if (options.HasFlag(IndexOptions.Search))
     {
         DocumentStore.ExecuteIndex(new UserSearchIndex());
     }
     if (options.HasFlag(IndexOptions.Sort))
     {
         DocumentStore.ExecuteIndex(new UserSortIndex());
     }
 }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 private void PutIndex(IndexOptions options)
 {
     if (options.HasFlag(IndexOptions.Search))
         DocumentStore.ExecuteIndex(new UserSearchIndex());
     if (options.HasFlag(IndexOptions.Sort))
         DocumentStore.ExecuteIndex(new UserSortIndex());
 }