Exemple #1
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition("ProfilePart", builder => builder
                                                          .WithDescription("Links content item to user.")
                                                          .WithDefaultPosition("0")
                                                          );

            _contentDefinitionManager.AlterTypeDefinition(Constants.ContentTypeName, type => type
                                                          .WithPart("ProfilePart")
                                                          );

            SchemaBuilder.CreateMapIndexTable(nameof(ProfilePartIndex), table => table
                                              .Column <string>("UserIdentifier", c => c.WithLength(UserIdenityMaxLength))
                                              );

            SchemaBuilder.AlterTable(nameof(ProfilePartIndex), table => table
                                     .CreateIndex("IDX_ProfilePartIndex_UserIdentifier", "UserIdentifier")
                                     );

            /**
             * Note:
             * Caused an issue on initial orchard recipe setup so commented this out
             */

            // await CreateProfilesForExistingUsersAsync();

            return(2);
        }
        public int Create()
        {
            _contentDefinitionManager.AlterTypeDefinition("Taxonomy", menu => menu
                                                          .Draftable()
                                                          .Versionable()
                                                          .Creatable()
                                                          .Listable()
                                                          .WithPart("TitlePart", part => part.WithPosition("1"))
                                                          .WithPart("AliasPart", part => part.WithPosition("2").WithSettings(new AliasPartSettings {
                Pattern = "{{ ContentItem | display_text | slugify }}"
            }))
                                                          .WithPart("TaxonomyPart", part => part.WithPosition("3"))
                                                          );

            SchemaBuilder.CreateMapIndexTable(nameof(TaxonomyIndex), table => table
                                              .Column <string>("TaxonomyContentItemId", c => c.WithLength(26))
                                              .Column <string>("ContentItemId", c => c.WithLength(26))
                                              .Column <string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
                                              .Column <string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
                                              .Column <string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
                                              .Column <string>("TermContentItemId", column => column.WithLength(26))
                                              );

            SchemaBuilder.AlterTable(nameof(TaxonomyIndex), table => table
                                     .CreateIndex("IDX_TaxonomyIndex_List", "ContentType", "ContentPart", "ContentField")
                                     );

            SchemaBuilder.AlterTable(nameof(TaxonomyIndex), table => table
                                     .CreateIndex("IDX_TaxonomyIndex_Search", "TermContentItemId")
                                     );

            // Return 2 to shortcut the second migration on new content definition schemas.
            return(1);
        }
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable <VoteItemIndex>(table => table
                                                              .Column <string>("User", c => c.WithLength(100))
                                                              .Column <string>("CorrelationId", c => c.WithLength(100))
                                                              .Column <string>("Description", c => c.WithLength(250))
                                                              .Column <string>("ContentType", c => c.WithLength(50))
                                                              .Column <string>("Hostname", c => c.WithLength(250))
                                                              .Column <string>("Dimension", c => c.WithLength(50))
                                                              .Column <string>("Value", c => c.WithLength(50))
                                                              .Column <DateTime>("CreatedUtc")
                                                              );

            SchemaBuilder.AlterTable(nameof(VoteItemIndex), table => table
                                     .CreateIndex("IDX_VoteItemIndex_CorrelationId", "CorrelationId")
                                     );

            SchemaBuilder.AlterTable(nameof(VoteItemIndex), table => table
                                     .CreateIndex("IDX_VoteItemIndex_User", "User")
                                     );

            SchemaBuilder.AlterTable(nameof(VoteItemIndex), table => table
                                     .CreateIndex("IDX_VoteItemIndex_User_CreatedUtc", "User", "CreatedUtc")
                                     );
            return(1);
        }
Exemple #4
0
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable <AuditTrailEventIndex>(table => table
                                                                     .Column <string>(nameof(AuditTrailEventIndex.EventId), column => column.WithLength(26))
                                                                     .Column <string>(nameof(AuditTrailEventIndex.Category), column => column.WithLength(64))
                                                                     .Column <string>(nameof(AuditTrailEventIndex.Name), column => column.WithLength(64))
                                                                     .Column <string>(nameof(AuditTrailEventIndex.CorrelationId), column => column.WithLength(26))
                                                                     .Column <string>(nameof(AuditTrailEventIndex.UserId), column => column.WithLength(26))
                                                                     .Column <string>(nameof(AuditTrailEventIndex.NormalizedUserName), column => column.Nullable().WithLength(255))
                                                                     .Column <DateTime>(nameof(AuditTrailEventIndex.CreatedUtc), column => column.Nullable()),
                                                                     collection: AuditTrailEvent.Collection);

            SchemaBuilder.AlterIndexTable <AuditTrailEventIndex>(table => table
                                                                 .CreateIndex("IDX_AuditTrailEventIndex_DocumentId",
                                                                              "DocumentId",
                                                                              nameof(AuditTrailEventIndex.EventId),
                                                                              nameof(AuditTrailEventIndex.Category),
                                                                              nameof(AuditTrailEventIndex.Name),
                                                                              nameof(AuditTrailEventIndex.CorrelationId),
                                                                              nameof(AuditTrailEventIndex.UserId),
                                                                              nameof(AuditTrailEventIndex.NormalizedUserName),
                                                                              nameof(AuditTrailEventIndex.CreatedUtc)
                                                                              ),
                                                                 collection: AuditTrailEvent.Collection
                                                                 );

            return(1);
        }
Exemple #5
0
        public async Task ShouldCreateIndexPropertyWithMaxBitKeys()
        {
            using (var connection = _store.Configuration.ConnectionFactory.CreateConnection())
            {
                await connection.OpenAsync();

                using (var transaction = connection.BeginTransaction(_store.Configuration.IsolationLevel))
                {
                    var builder = new SchemaBuilder(_store.Configuration, transaction);

                    builder
                    .DropMapIndexTable <PropertyIndex>();

                    builder
                    .CreateMapIndexTable <PropertyIndex>(column => column
                                                         .Column <string>(nameof(PropertyIndex.Name), col => col.WithLength(767))
                                                         .Column <bool>(nameof(PropertyIndex.ForRent))
                                                         .Column <bool>(nameof(PropertyIndex.IsOccupied))
                                                         .Column <string>(nameof(PropertyIndex.Location), col => col.WithLength(384))
                                                         );

                    builder
                    .AlterTable(nameof(PropertyIndex), table => table
                                .CreateIndex("IDX_Property", "Name", "ForRent", "IsOccupied"));

                    transaction.Commit();
                }
            }
        }
Exemple #6
0
 public int UpdateFrom2()
 {
     SchemaBuilder.CreateMapIndexTable(nameof(UserByClaimIndex), table => table
                                       .Column <string>(nameof(UserByClaimIndex.ClaimType))
                                       .Column <string>(nameof(UserByClaimIndex.ClaimValue)));
     return(3);
 }
Exemple #7
0
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable <WorkflowTypeIndex>(table => table
                                                                  .Column <string>("WorkflowTypeId")
                                                                  .Column <string>("Name")
                                                                  .Column <bool>("IsEnabled")
                                                                  .Column <bool>("HasStart")
                                                                  );

            SchemaBuilder.CreateMapIndexTable <WorkflowTypeStartActivitiesIndex>(table => table
                                                                                 .Column <string>("WorkflowTypeId")
                                                                                 .Column <string>("Name")
                                                                                 .Column <bool>("IsEnabled")
                                                                                 .Column <string>("StartActivityId")
                                                                                 .Column <string>("StartActivityName")
                                                                                 );

            SchemaBuilder.CreateMapIndexTable <WorkflowIndex>(table => table
                                                              .Column <string>("WorkflowTypeId")
                                                              .Column <string>("WorkflowId")
                                                              .Column <string>("WorkflowStatus")
                                                              .Column <DateTime>("CreatedUtc")
                                                              );

            SchemaBuilder.CreateMapIndexTable <WorkflowBlockingActivitiesIndex>(table => table
                                                                                .Column <string>("ActivityId")
                                                                                .Column <string>("ActivityName")
                                                                                .Column <bool>("ActivityIsStart")
                                                                                .Column <string>("WorkflowTypeId")
                                                                                .Column <string>("WorkflowId")
                                                                                .Column <string>("WorkflowCorrelationId")
                                                                                );

            return(2);
        }
Exemple #8
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition(nameof(AliasPart), builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides a way to define custom aliases for content items."));

            // NOTE: The Alias Length has been upgraded from 64 characters to 767.
            // For existing SQL databases update the AliasPartIndex tables Alias column length manually.
            // INFO: The Alias Length is now of 740 chars, but this is only used on a new installation.
            SchemaBuilder.CreateMapIndexTable <AliasPartIndex>(table => table
                                                               .Column <string>("Alias", col => col.WithLength(AliasPart.MaxAliasLength))
                                                               .Column <string>("ContentItemId", c => c.WithLength(26))
                                                               .Column <bool>("Latest", c => c.WithDefault(false))
                                                               .Column <bool>("Published", c => c.WithDefault(true))
                                                               );

            SchemaBuilder.AlterIndexTable <AliasPartIndex>(table => table
                                                           .CreateIndex("IDX_AliasPartIndex_DocumentId",
                                                                        "DocumentId",
                                                                        "Alias",
                                                                        "ContentItemId",
                                                                        "Published",
                                                                        "Latest")
                                                           );

            // Shortcut other migration steps on new content definition schemas.
            return(4);
        }
Exemple #9
0
        // reflection

        public int Create()
        {
            contentDefinitionManager.AlterPartDefinition(
                nameof(PersonPart),
                part => part.Attachable()
                .WithField(nameof(PersonPart.Biography), field => field.OfType(nameof(TextField))
                           .WithDisplayName("Biography")
                           .WithEditor("TextArea")
                           .WithSettings(new TextFieldSettings
            {
                Hint = "Person's biography"
            })));

            SchemaBuilder.CreateMapIndexTable(
                nameof(PersonPartIndex),
                table => table
                .Column <string>(nameof(PersonPartIndex.ContentItemId), x => x.WithLength(26))
                .Column <int>(nameof(PersonPartIndex.Handedness)));
            SchemaBuilder.AlterTable(
                nameof(PersonPartIndex),
                table => table
                .CreateIndex(
                    $"IDX_{nameof(PersonPartIndex)}_{nameof(PersonPartIndex.Handedness)}",
                    nameof(PersonPartIndex.Handedness)));

            contentDefinitionManager.AlterTypeDefinition("PersonWidget", type => type
                                                         .DisplayedAs("Person Widget")
                                                         .Draftable()
                                                         .Versionable()
                                                         .WithPart("PersonPage")
                                                         .WithPart("PersonPart")
                                                         .Stereotype("Widget")); // categorization for content types

            return(1);
        }
Exemple #10
0
        public async Task ThrowsWhenIndexKeyLengthExceeded()
        {
            using (var connection = _store.Configuration.ConnectionFactory.CreateConnection())
            {
                await connection.OpenAsync();

                using (var transaction = connection.BeginTransaction(_store.Configuration.IsolationLevel))
                {
                    var builder = new SchemaBuilder(_store.Configuration, transaction);

                    builder
                    .DropMapIndexTable <PropertyIndex>();

                    builder
                    .CreateMapIndexTable <PropertyIndex>(column => column
                                                         .Column <string>(nameof(PropertyIndex.Name), col => col.WithLength(769))
                                                         .Column <bool>(nameof(PropertyIndex.ForRent))
                                                         .Column <bool>(nameof(PropertyIndex.IsOccupied))
                                                         .Column <string>(nameof(PropertyIndex.Location), col => col.WithLength(768))
                                                         );

                    Assert.Throws <MySqlException>(() => builder
                                                   .AlterTable(nameof(PropertyIndex), table => table
                                                               .CreateIndex("IDX_Property", "Name")));
                }
            }
        }
Exemple #11
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition("AutoroutePart", builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides a custom url for your content item."));

            SchemaBuilder.CreateMapIndexTable <AutoroutePartIndex>(table => table
                                                                   .Column <string>("ContentItemId", c => c.WithLength(26))
                                                                   .Column <string>("ContainedContentItemId", c => c.WithLength(26))
                                                                   .Column <string>("JsonPath", c => c.Unlimited())
                                                                   .Column <string>("Path", col => col.WithLength(AutoroutePart.MaxPathLength))
                                                                   .Column <bool>("Published")
                                                                   .Column <bool>("Latest")
                                                                   );

            SchemaBuilder.AlterTable(nameof(AutoroutePartIndex), table => table
                                     .CreateIndex("IDX_AutoroutePartIndex_ContentItemIds", "ContentItemId", "ContainedContentItemId")
                                     );

            SchemaBuilder.AlterTable(nameof(AutoroutePartIndex), table => table
                                     .CreateIndex("IDX_AutoroutePartIndex_State", "Published", "Latest")
                                     );

            // Return 4 to shortcut the second migration on new content definition schemas.
            return(4);
        }
Exemple #12
0
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable(nameof(ContentItemIndex), table => table
                                              .Column <string>("ContentItemId", c => c.WithLength(26))
                                              .Column <string>("ContentItemVersionId", c => c.WithLength(26))
                                              .Column <bool>("Latest")
                                              .Column <bool>("Published")
                                              .Column <string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
                                              .Column <DateTime>("ModifiedUtc", column => column.Nullable())
                                              .Column <DateTime>("PublishedUtc", column => column.Nullable())
                                              .Column <DateTime>("CreatedUtc", column => column.Nullable())
                                              .Column <string>("Owner", column => column.Nullable().WithLength(ContentItemIndex.MaxOwnerSize))
                                              .Column <string>("Author", column => column.Nullable().WithLength(ContentItemIndex.MaxAuthorSize))
                                              .Column <string>("DisplayText", column => column.Nullable().WithLength(ContentItemIndex.MaxDisplayTextSize))
                                              );

            SchemaBuilder.AlterTable(nameof(ContentItemIndex), table => table
                                     .CreateIndex("IDX_ContentItemIndex_ContentItemId", "ContentItemId", "Latest", "Published", "CreatedUtc")
                                     );

            SchemaBuilder.AlterTable(nameof(ContentItemIndex), table => table
                                     .CreateIndex("IDX_ContentItemIndex_ContentItemVersionId", "ContentItemVersionId")
                                     );

            SchemaBuilder.AlterTable(nameof(ContentItemIndex), table => table
                                     .CreateIndex("IDX_ContentItemIndex_DisplayText", "DisplayText")
                                     );

            return(3);
        }
Exemple #13
0
 public int UpdateFrom1()
 {
     SchemaBuilder.CreateMapIndexTable <UserByLoginInfoIndex>(table => table
                                                              .Column <string>("LoginProvider")
                                                              .Column <string>("ProviderKey"));
     return(2);
 }
Exemple #14
0
        // This is a sequenced migration. On a new schemas this is complete after UpdateFrom2.
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable <UserIndex>(table => table
                                                          .Column <string>("NormalizedUserName") // TODO These should have defaults. on SQL Server they will fall at 255. Exceptions are currently thrown if you go over that.
                                                          .Column <string>("NormalizedEmail")
                                                          .Column <bool>("IsEnabled", c => c.NotNull().WithDefault(true))
                                                          .Column <string>("UserId")
                                                          );

            SchemaBuilder.AlterTable(nameof(UserIndex), table => table
                                     .CreateIndex("IDX_UserIndex_IsEnabled", "DocumentId", "IsEnabled")
                                     );

            SchemaBuilder.AlterTable(nameof(UserIndex), table => table
                                     .CreateIndex("IDX_UserIndex_UserId", "DocumentId", "UserId")
                                     );

            SchemaBuilder.AlterTable(nameof(UserIndex), table => table
                                     // This index will be used for lookups when logging in.
                                     .CreateIndex("IDX_UserIndex_UserName", "DocumentId", "NormalizedUserName")
                                     );

            SchemaBuilder.AlterTable(nameof(UserIndex), table => table
                                     .CreateIndex("IDX_UserIndex_Email", "DocumentId", "NormalizedEmail")
                                     );

            SchemaBuilder.CreateReduceIndexTable <UserByRoleNameIndex>(table => table
                                                                       .Column <string>("RoleName")
                                                                       .Column <int>("Count")
                                                                       );

            return(UpdateFrom1());
        }
        public int Create()
        {
            // Now you can configure PersonPart. For example you can add content fields (as mentioned earlier) here.
            _contentDefinitionManager.AlterPartDefinition(nameof(PersonPart), part => part
                                                          // Each field has its own configuration. Here you will give a display name for it and add some
                                                          // additional settings like a hint to be displayed in the editor.
                                                          .WithField(nameof(PersonPart.Biography), field => field
                                                                     .OfType(nameof(TextField))
                                                                     .WithDisplayName("Biography")
                                                                     .Hint("Person's biography")
                                                                     .WithSetting("Editor", "TextArea")));

            // We create a new content type. Note that there's only an alter method: this will create the type if it
            // doesn't exist or modify it if it does. Make sure you understand what content types are:
            // http://docs.orchardproject.net/Documentation/Content-types. The content type's name is arbitrary, but
            // choose a meaningful one. Notice that we attach parts by specifying their name. For our own parts we use
            // nameof(): this is not mandatory but serves great if we change the part's name during development.
            _contentDefinitionManager.AlterTypeDefinition("Person", builder => builder
                                                          .Creatable()
                                                          .Listable()
                                                          .WithPart(nameof(PersonPart))
                                                          );

            // This one will create an index table for the PersonPartIndex as explained in the BookMigrations file.
            SchemaBuilder.CreateMapIndexTable(nameof(PersonPartIndex), table => table
                                              .Column <DateTime>(nameof(PersonPartIndex.BirthDateUtc))
                                              .Column <string>(nameof(PersonPartIndex.ContentItemId), c => c.WithLength(26))
                                              );

            return(1);
        }
Exemple #16
0
        static async Task MainAsync(string[] args)
        {
            var store = new Store(
                new Configuration()
                .UseSqlServer(@"Data Source =.; Initial Catalog = yessql; Integrated Security = True")
                .SetTablePrefix("Bench")
                );

            await store.InitializeAsync();

            using (var session = store.CreateSession())
            {
                var builder = new SchemaBuilder(session);

                builder.CreateMapIndexTable(nameof(UserByName), c => c
                                            .Column <string>("Name")
                                            .Column <bool>("Adult")
                                            .Column <int>("Age")
                                            );
            }

            store.RegisterIndexes <UserIndexProvider>();

            using (var session = store.CreateSession())
            {
                var user = await session.Query <User>().FirstOrDefaultAsync();

                Assert.Null(user);

                var bill = new User
                {
                    Name  = "Bill",
                    Adult = true,
                    Age   = 1
                };


                session.Save(bill);
            }

            using (var session = store.CreateSession())
            {
                var user = await session.Query <User, UserByName>().Where(x => x.Adult == true).FirstOrDefaultAsync();

                Assert.NotNull(user);

                user = await session.Query <User, UserByName>().Where(x => x.Age == 1).FirstOrDefaultAsync();

                Assert.NotNull(user);

                user = await session.Query <User, UserByName>().Where(x => x.Age == 1 && x.Adult).FirstOrDefaultAsync();

                Assert.NotNull(user);

                user = await session.Query <User, UserByName>().Where(x => x.Name.StartsWith("B")).FirstOrDefaultAsync();

                Assert.NotNull(user);
            }
        }
Exemple #17
0
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable(nameof(WorkflowServerIndex), table => table
                                              .Column <string>("WorkflowServerId")
                                              );

            return(1);
        }
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable(nameof(LayerMetadataIndex), table => table
                                              .Column <string>("Zone", c => c.WithLength(64))
                                              );

            return(1);
        }
Exemple #19
0
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable("Product", table => table
                                              .Column <string>("ProductName", column => column.WithLength(50))
                                              .Column <int>("ProductPrice", column => column.WithLength(10)));

            return(1);
        }
Exemple #20
0
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable(nameof(RecipeResultIndex), table => table
                                              .Column <string>("ExecutionId")
                                              );

            return(1);
        }
Exemple #21
0
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable(nameof(DeploymentPlanIndex), table => table
                                              .Column <string>("Name")
                                              );

            return(1);
        }
Exemple #22
0
        static void Main(string[] args)
        {
            var configuration = new Configuration()
            {
                ConnectionFactory = new DbConnectionFactory <SqlConnection>(@"Data Source =.; Initial Catalog = yessql; Integrated Security = True"),
                //ConnectionFactory = new DbConnectionFactory<SQLiteConnection>(@"Data Source=:memory:", true),
                DocumentStorageFactory = new LightningDocumentStorageFactory("db"),
                TablePrefix            = "Bench"
            };

            var _store = new Store(configuration);

            _store.InitializeAsync().Wait();

            using (var session = _store.CreateSession())
            {
                var builder = new SchemaBuilder(session);

                builder.CreateMapIndexTable(nameof(UserByName), c => c
                                            .Column <string>("Name")
                                            .Column <bool>("Adult")
                                            .Column <int>("Age")
                                            );
            }

            _store.RegisterIndexes <UserIndexProvider>();

            using (var session = _store.CreateSession())
            {
                var user = session.QueryAsync <User>().FirstOrDefault().Result;
                Assert.Null(user);

                var bill = new User
                {
                    Name  = "Bill",
                    Adult = true,
                    Age   = 1
                };


                session.Save(bill);
            }

            using (var session = _store.CreateSession())
            {
                var user = session.QueryAsync <User, UserByName>().Where(x => x.Adult == true).FirstOrDefault().Result;
                Assert.NotNull(user);

                user = session.QueryAsync <User, UserByName>().Where(x => x.Age == 1).FirstOrDefault().Result;
                Assert.NotNull(user);

                user = session.QueryAsync <User, UserByName>().Where(x => x.Age == 1 && x.Adult).FirstOrDefault().Result;
                Assert.NotNull(user);

                user = session.QueryAsync <User, UserByName>().Where(x => x.Name.StartsWith("B")).FirstOrDefault().Result;
                Assert.NotNull(user);
            }
        }
Exemple #23
0
        public int Create()
        {
            _contentDefinitionManager.AlterTypeDefinition("Taxonomy", taxonomy => taxonomy
                                                          .Draftable()
                                                          .Versionable()
                                                          .Creatable()
                                                          .Listable()
                                                          .WithPart("TitlePart", part => part.WithPosition("1"))
                                                          .WithPart("AliasPart", part => part
                                                                    .WithPosition("2")
                                                                    .WithSettings(new AliasPartSettings
            {
                Pattern = "{{ Model.ContentItem | display_text | slugify }}"
            }))
                                                          .WithPart("AutoroutePart", part => part
                                                                    .WithPosition("3")
                                                                    .WithSettings(new AutoroutePartSettings
            {
                Pattern = "{{ Model.ContentItem | display_text | slugify }}",
                AllowRouteContainedItems = true
            }))
                                                          .WithPart("TaxonomyPart", part => part.WithPosition("4"))
                                                          );

            SchemaBuilder.CreateMapIndexTable <TaxonomyIndex>(table => table
                                                              .Column <string>("TaxonomyContentItemId", c => c.WithLength(26))
                                                              .Column <string>("ContentItemId", c => c.WithLength(26))
                                                              .Column <string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
                                                              .Column <string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
                                                              .Column <string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
                                                              .Column <string>("TermContentItemId", column => column.WithLength(26))
                                                              .Column <bool>("Published", c => c.WithDefault(true))
                                                              .Column <bool>("Latest", c => c.WithDefault(false))
                                                              );

            SchemaBuilder.AlterIndexTable <TaxonomyIndex>(table => table
                                                          .CreateIndex("IDX_TaxonomyIndex_DocumentId",
                                                                       "DocumentId",
                                                                       "TaxonomyContentItemId",
                                                                       "ContentItemId",
                                                                       "TermContentItemId",
                                                                       "Published",
                                                                       "Latest")
                                                          );

            SchemaBuilder.AlterIndexTable <TaxonomyIndex>(table => table
                                                          .CreateIndex("IDX_TaxonomyIndex_DocumentId_ContentType",
                                                                       "DocumentId",
                                                                       "ContentType",
                                                                       "ContentPart",
                                                                       "ContentField",
                                                                       "Published",
                                                                       "Latest")
                                                          );

            // Shortcut other migration steps on new content definition schemas.
            return(5);
        }
Exemple #24
0
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable(nameof(UserIndex), table => table
                                              .Column <string>("NormalizedUserName")
                                              .Column <string>("NormalizedEmail")
                                              );

            return(1);
        }
Exemple #25
0
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable <WorkflowSettingIndex>(
                table => table
                .Column <string>(nameof(WorkflowSettingIndex.SettingId)),
                CollectionNames.WorkflowSettings);

            return(1);
        }
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable <TenantBillingDetailsIndex>(table => table
                                                                          .Column <string>("TenantId")
                                                                          .Column <string>("TenantName")
                                                                          );

            return(1);
        }
Exemple #27
0
        static async Task MainAsync(string[] args)
        {
            var configuration = new Configuration()
                                .UseSqlServer(@"Data Source =.; Initial Catalog = yessql; Integrated Security = True")
                                .SetTablePrefix("Bench");

            using (var connection = configuration.ConnectionFactory.CreateConnection())
            {
                await connection.OpenAsync();

                using (var transaction = connection.BeginTransaction(configuration.IsolationLevel))
                {
                    var builder = new SchemaBuilder(configuration, transaction);

                    builder.CreateMapIndexTable <UserByName>(c => c
                                                             .Column <string>("Name")
                                                             .Column <bool>("Adult")
                                                             .Column <int>("Age")
                                                             );

                    transaction.Commit();
                }
            }

            var store = await StoreFactory.CreateAndInitializeAsync(configuration);

            store.RegisterIndexes <UserIndexProvider>();

            using (var session = store.CreateSession())
            {
                var user = await session.Query <User>().FirstOrDefaultAsync();

                var bill = new User
                {
                    Name  = "Bill",
                    Adult = true,
                    Age   = 1
                };


                session.Save(bill);

                await session.SaveChangesAsync();
            }

            using (var session = store.CreateSession())
            {
                var user = await session.Query <User, UserByName>().Where(x => x.Adult == true).FirstOrDefaultAsync();

                user = await session.Query <User, UserByName>().Where(x => x.Age == 1).FirstOrDefaultAsync();

                user = await session.Query <User, UserByName>().Where(x => x.Age == 1 && x.Adult).FirstOrDefaultAsync();

                user = await session.Query <User, UserByName>().Where(x => x.Name.StartsWith("B")).FirstOrDefaultAsync();
            }
        }
Exemple #28
0
        public int UpdateFrom2()
        {
            SchemaBuilder.CreateMapIndexTable <UserByClaimIndex>(table => table
                                                                 .Column <string>(nameof(UserByClaimIndex.ClaimType))
                                                                 .Column <string>(nameof(UserByClaimIndex.ClaimValue)),
                                                                 null);

            // Return 6 here to skip migrations on new database schemas.
            return(6);
        }
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition("ProductPart", part => part.Attachable());

            SchemaBuilder.CreateMapIndexTable("ProductPartIndex", table => table
                                              .Column <string>(nameof(ProductPartIndex.ContentItemId), column => column.WithLength(26))
                                              .Column <decimal>(nameof(ProductPartIndex.UnitPrice))
                                              );

            return(1);
        }
Exemple #30
0
        public int Create()
        {
            SchemaBuilder.CreateMapIndexTable(nameof(RecipeResultIndex), table => table
                                              .Column <string>("ExecutionId")
                                              .Column <bool>("IsCompleted")
                                              .Column <int>("TotalSteps")
                                              .Column <int>("CompletedSteps")
                                              );

            return(1);
        }