private static FluentMappingBuilder RegisterAdvertisementAggregates(this FluentMappingBuilder builder)
        {
            builder.Entity <AdvertisementAggregates::Order>()
            .HasSchemaName(AdvertisementAggregatesSchema)
            .HasPrimaryKey(x => x.Id);

            builder.Entity <AdvertisementAggregates::Order.MissingAdvertisementReference>()
            .HasSchemaName(AdvertisementAggregatesSchema)
            .HasPrimaryKey(x => new { x.OrderId, x.OrderPositionId, x.CompositePositionId, x.PositionId })
            .HasIndex(x => x.AdvertisementIsOptional);

            builder.Entity <AdvertisementAggregates::Order.MissingOrderPositionAdvertisement>()
            .HasSchemaName(AdvertisementAggregatesSchema)
            .HasPrimaryKey(x => new { x.OrderId, x.OrderPositionId, x.PositionId });

            builder.Entity <AdvertisementAggregates::Order.AdvertisementFailedReview>()
            .HasSchemaName(AdvertisementAggregatesSchema)
            .HasPrimaryKey(x => new { x.OrderId, x.AdvertisementId });

            // таблица маленькая, можно обойтись без индексов
            builder.Entity <AdvertisementAggregates::Order.AdvertisementNotBelongToFirm>()
            .HasSchemaName(AdvertisementAggregatesSchema);

            return(builder);
        }
        private static void MapJournalRow(IProviderConfig <JournalTableConfig> config,
                                          FluentMappingBuilder fmb)
        {
            var tableConfig       = config.TableConfig;
            var journalRowBuilder = fmb.Entity <JournalRow>()
                                    .HasSchemaName(tableConfig.SchemaName)
                                    .HasTableName(tableConfig.TableName)
                                    .Member(r => r.deleted).HasColumnName(tableConfig.ColumnNames.Deleted)
                                    .Member(r => r.manifest).HasColumnName(tableConfig.ColumnNames.Manifest)
                                    .HasLength(500)
                                    .Member(r => r.message).HasColumnName(tableConfig.ColumnNames.Message).IsNullable(false)
                                    .Member(r => r.ordering).HasColumnName(tableConfig.ColumnNames.Ordering)
                                    .Member(r => r.tags).HasLength(100)
                                    .HasColumnName(tableConfig.ColumnNames.Tags)
                                    .Member(r => r.Identifier)
                                    .HasColumnName(tableConfig.ColumnNames.Identitifer)
                                    .Member(r => r.persistenceId)
                                    .HasColumnName(tableConfig.ColumnNames.PersistenceId).HasLength(255).IsNullable(false)
                                    .Member(r => r.sequenceNumber)
                                    .HasColumnName(tableConfig.ColumnNames.SequenceNumber)
                                    .Member(r => r.Timestamp)
                                    .HasColumnName(tableConfig.ColumnNames.Created);

            if (config.ProviderName.ToLower().Contains("sqlite"))
            {
                journalRowBuilder.Member(r => r.ordering).IsPrimaryKey().HasDbType("INTEGER")
                .IsIdentity();
            }
            else
            {
                journalRowBuilder.Member(r => r.ordering).IsIdentity()
                .Member(r => r.persistenceId).IsPrimaryKey()
                .Member(r => r.sequenceNumber).IsPrimaryKey();
            }

            //Probably overkill, but we only set Metadata Mapping if specified
            //That we are in delete compatibility mode.
            if (config.IDaoConfig.SqlCommonCompatibilityMode)
            {
                fmb.Entity <JournalMetaData>()
                .HasTableName(tableConfig.MetadataTableName)
                .HasSchemaName(tableConfig.SchemaName)
                .Member(r => r.PersistenceId)
                .HasColumnName(tableConfig.MetadataColumnNames.PersistenceId)
                .HasLength(255)
                .Member(r => r.SequenceNumber)
                .HasColumnName(tableConfig.MetadataColumnNames.SequenceNumber)
                ;
            }
        }
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <UserAttribute>().HasTableName(nameof(UserAttribute))
     .HasSchemaName(TableSchemaConst.Auth)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id);
 }
        private static FluentMappingBuilder RegisterAdvertisementAggregates(this FluentMappingBuilder builder)
        {
            builder.Entity <AdvertisementAggregates::Order>()
            .HasSchemaName(AdvertisementAggregatesSchema)
            .HasPrimaryKey(x => x.Id);
            builder.Entity <AdvertisementAggregates::Order.MissingAdvertisementReference>()
            .HasSchemaName(AdvertisementAggregatesSchema);
            builder.Entity <AdvertisementAggregates::Order.MissingOrderPositionAdvertisement>()
            .HasSchemaName(AdvertisementAggregatesSchema);
            builder.Entity <AdvertisementAggregates::Order.AdvertisementFailedReview>()
            .HasSchemaName(AdvertisementAggregatesSchema);
            builder.Entity <AdvertisementAggregates::Order.AdvertisementNotBelongToFirm>()
            .HasSchemaName(AdvertisementAggregatesSchema);

            return(builder);
        }
示例#5
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <User>()
     .HasTableName(nameof(User))
     .HasSchemaName(TableSchemaConst.Auth)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id)
     .Association(e => e.UserInfo, (user, userInfo) => user.Id == userInfo.Id)
     .Association(e => e.CreatedBy, (user, createdBy) => user.CreatedById == createdBy.Id)
     .Association(e => e.CreatedUsers, (user, createdUsers) => user.Id == createdUsers.Id)
     .Association(e => e.UpdatedBy, (user, updatedBy) => user.UpdatedById == updatedBy.Id)
     .Association(e => e.UpdatedUsers, (user, updatedUsers) => user.Id == updatedUsers.Id)
     .Association(e => e.UserRoles, (user, userRoles) => user.Id == userRoles.UserId)
     .Association(e => e.CreatedRoles, (user, role) => user.Id == role.CreatedById)
     .Association(e => e.UpdatedRoles, (user, role) => user.Id == role.UpdatedById)
     .Association(e => e.Status, (user, status) => user.StatusId == status.Id)
     .Association(e => e.CreatedAuthorizationPolicies,
                  (user, authorizationPolicy) => user.Id == authorizationPolicy.CreatedById)
     .Association(e => e.UpdatedAuthorizationPolicies,
                  (user, authorizationPolicy) => user.Id == authorizationPolicy.UpdatedById)
     .Association(e => e.UserAuthorizationPolicies,
                  (user, userAuthorizationPolicy) => user.Id == userAuthorizationPolicy.UserId)
     .Association(e => e.GrantedRoleAuthorizationPolicies,
                  (user, roleAuthorizationPolicy) => user.Id == roleAuthorizationPolicy.GrantedById);
 }
        /// <summary>
        /// Apply this mapping configuration
        /// </summary>
        /// <param name="modelBuilder">The builder being used to construct the model for the database context</param>
        public void ApplyConfiguration(FluentMappingBuilder modelBuilder)
        {
            var builder = modelBuilder.Entity <TEntity>();

            builder.HasPrimaryKey(entity => entity.Id).HasIdentity(entity => entity.Id);

            Configure(builder);
        }
示例#7
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <RoleClaim>().HasTableName(nameof(RoleClaim))
     .HasSchemaName(TableSchemaConst.Auth)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id)
     .Association(c => c.Role, (roleClaim, role) => roleClaim.RoleId == role.Id);
 }
        private static FluentMappingBuilder RegisterAccountAggregates(this FluentMappingBuilder builder)
        {
            builder.Entity <AccountAggregates::Order>()
            .HasSchemaName(AccountAggregatesSchema)
            .HasPrimaryKey(x => x.Id);

            builder.Entity <AccountAggregates::Order.DebtPermission>()
            .HasSchemaName(AccountAggregatesSchema);

            builder.Entity <AccountAggregates::Account>()
            .HasSchemaName(AccountAggregatesSchema);

            builder.Entity <AccountAggregates::Account.AccountPeriod>()
            .HasSchemaName(AccountAggregatesSchema);

            return(builder);
        }
示例#9
0
        private static FluentMappingBuilder RegisterWebApp(this FluentMappingBuilder builder)
        {
            builder.Entity <Lock>()
            .HasSchemaName(WebAppSchema)
            .HasPrimaryKey(x => x.Id);

            return(builder);
        }
示例#10
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <Shortcut>()
     .HasTableName(nameof(Shortcut))
     .HasSchemaName(TableSchemaConst.Dbo)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id);
 }
        private static FluentMappingBuilder RegisterSystemAggregates(this FluentMappingBuilder builder)
        {
            builder.Entity <SystemAggregates::SystemStatus>()
            .HasSchemaName(SystemAggregatesSchema)
            .HasPrimaryKey(x => x.Id);

            return(builder);
        }
示例#12
0
 static void MapAa(FluentMappingBuilder fb)
 {
     fb.Entity <Aa>()
     .HasTableName("Aa")
     .Ignore(x => x.NotInDb)
     .Property(x => x.Id).IsPrimaryKey()
     .Property(x => x.Name).HasColumnName("Name");
 }
示例#13
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <UserClaim>().HasTableName(nameof(UserClaim))
     .HasSchemaName(TableSchemaConst.Auth)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id)
     .Association(c => c.User, (userClaim, user) => userClaim.UserId == user.Id);
 }
示例#14
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <Status>().HasTableName(nameof(Status))
     .HasSchemaName(TableSchemaConst.Auth)
     .HasPrimaryKey(x => x.Id)
     .HasIdentity(x => x.Id)
     .Association(c => c.Users, (status, users) => status.Id == users.StatusId);
 }
        private static FluentMappingBuilder RegisterFirmAggregates(this FluentMappingBuilder builder)
        {
            builder.Entity <FirmAggregates::Firm>()
            .HasSchemaName(FirmAggregatesSchema)
            .HasPrimaryKey(x => x.Id);

            builder.Entity <FirmAggregates::Firm.CategoryPurchase>()
            .HasSchemaName(FirmAggregatesSchema)
            .HasIndex(x => new { x.FirmId, x.Begin, x.End, x.CategoryId }, x => new { x.Scope });

            builder.Entity <FirmAggregates::Order>()
            .HasSchemaName(FirmAggregatesSchema)
            .HasPrimaryKey(x => x.Id)
            .HasIndex(x => new { x.FirmId, x.Begin, x.End }, x => new { x.Id, x.Scope });

            builder.Entity <FirmAggregates::Order.FirmOrganiationUnitMismatch>()
            .HasSchemaName(FirmAggregatesSchema);

            builder.Entity <FirmAggregates::Order.InvalidFirm>()
            .HasSchemaName(FirmAggregatesSchema);

            builder.Entity <FirmAggregates::Order.PartnerPosition>()
            .HasSchemaName(FirmAggregatesSchema);

            builder.Entity <FirmAggregates::Order.FmcgCutoutPosition>()
            .HasSchemaName(FirmAggregatesSchema);

            return(builder);
        }
        private static FluentMappingBuilder RegisterEvents(this FluentMappingBuilder builder)
        {
            builder.Entity <EventRecord>()
            .HasSchemaName(EventsSchema)
            .HasPrimaryKey(x => x.Id)
            .HasIdentity(x => x.Id);

            return(builder);
        }
示例#17
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <Country>()
     .HasTableName(nameof(Country))
     .HasSchemaName(TableSchemaConst.Auth)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id)
     .Association(c => c.UserInfos, (country, userInfos) => country.Id == userInfos.CountryId);
 }
示例#18
0
        public override void Map(FluentMappingBuilder builder)
        {
            builder.Entity <UserToken>().HasTableName(nameof(UserToken))
            .HasSchemaName(TableSchemaConst.Auth)
            .HasIdentity(x => x.Id)
            .HasPrimaryKey(x => x.Id)
            .Association(c => c.User, (userToken, user) => userToken.UserId == user.Id);

            builder.Entity <UserToken>()
            .Property(x => x.Name)
            .IsNullable(false)
            .HasLength(255);

            builder.Entity <UserToken>()
            .Property(x => x.Value)
            .IsNullable(false)
            .HasLength(255);
        }
示例#19
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <UserPhoto>()
     .HasTableName(nameof(UserPhoto))
     .HasSchemaName(TableSchemaConst.Dbo)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id)
     .Association(x => x.UserPhotoType, (userPhoto, type) => userPhoto.TypeId == type.Id);
 }
示例#20
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder
     .Entity <Gender>()
     .HasTableName(nameof(Gender))
     .HasSchemaName(TableSchemaConst.Auth)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id)
     .Association(x => x.UserInfos, (gender, userInfo) => gender.Id == userInfo.GenderId);
 }
示例#21
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <UserInfo>()
     .HasTableName(nameof(UserInfo))
     .HasSchemaName(TableSchemaConst.Auth)
     .HasPrimaryKey(x => x.Id)
     .Association(e => e.User, (userInfo, user) => userInfo.Id == user.Id)
     .Association(e => e.Gender, (user, gender) => user.GenderId == gender.Id)
     .Association(e => e.Country, (user, country) => user.CountryId == country.Id);
 }
示例#22
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <ProductPrice>()
     .HasTableName(nameof(ProductPrice))
     .HasSchemaName(TableSchemaConst.Dbo)
     .HasPrimaryKey(x => x.Id)
     .HasIdentity(x => x.Id)
     .Association(x => x.Product,
                  (productPrice, product) => productPrice.ProductId == product.Id);
 }
示例#23
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <Farm>()
     .HasTableName(nameof(Farm))
     .HasSchemaName(TableSchemaConst.Dbo)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id)
     .Association(x => x.FarmType,
                  (farm, farmType) => farm.FarmTypeId == farmType.Id);
 }
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <ProductAttribute>()
     .HasTableName(nameof(ProductAttribute))
     .HasSchemaName(TableSchemaConst.Dbo)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id)
     .Association(x => x.ProductAttributeRelations,
                  (attribute, relation) => attribute.Id == relation.ProductAttributeId);
 }
示例#25
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <Article>()
     .HasTableName(nameof(Article))
     .HasSchemaName(TableSchemaConst.Dbo)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id)
     .Association(x => x.ArticleCategory,
                  (article, category) => article.ArticleCategoryId == category.Id)
     .Association(x => x.ArticlePictures, (article, articlePicture) => article.Id == articlePicture.ArticleId);
 }
示例#26
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <Role>().HasTableName(nameof(Role))
     .HasSchemaName(TableSchemaConst.Auth)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id)
     .Association(c => c.UserRoles, (role, userRoles) => role.Id == userRoles.RoleId)
     .Association(c => c.CreatedBy, (role, createdBy) => role.CreatedById == createdBy.Id)
     .Association(c => c.UpdatedBy, (role, updatedBy) => role.UpdatedById == updatedBy.Id)
     .Association(c => c.RoleAuthorizationPolicies, (role, roleAuthorizationPolicy) => role.Id == roleAuthorizationPolicy.RoleId);
 }
示例#27
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <FarmProduct>()
     .HasTableName(nameof(FarmProduct))
     .HasSchemaName(TableSchemaConst.Dbo)
     .HasPrimaryKey(x => x.Id)
     .HasIdentity(x => x.Id)
     .Association(x => x.Product,
                  (productFarm, product) => productFarm.ProductId == product.Id)
     .Association(x => x.Farm,
                  (productFarm, farm) => productFarm.FarmId == farm.Id);
 }
示例#28
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <ProductCategory>()
     .HasTableName(nameof(ProductCategory))
     .HasSchemaName(TableSchemaConst.Dbo)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id)
     .Association(x => x.ParentCategory,
                  (productCategory, parentCategory) => productCategory.ParentId == parentCategory.Id)
     .Association(x => x.ChildCategories,
                  (productCategory, childCategories) => productCategory.Id == childCategories.ParentId);
 }
示例#29
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <UserRole>().HasTableName(nameof(UserRole))
     .HasSchemaName(TableSchemaConst.Auth)
     .HasPrimaryKey(x => new {
         x.UserId,
         x.RoleId
     })
     .Association(c => c.User, (userRole, user) => userRole.UserId == user.Id)
     .Association(c => c.Role, (userRole, role) => userRole.RoleId == role.Id)
     .Association(c => c.GrantedBy, (userRole, grantedBy) => userRole.GrantedById == grantedBy.Id);
 }
示例#30
0
        /// <summary>
        /// Registers the mappings for the <see cref="MigrationInfo" /> instance.
        /// </summary>
        /// <param name="builder">The LinqToDB builder that is used to create mappings from model classes to database tables.</param>
        /// <param name="tableName">The name of the table that will hold records for migration infos (optional). Defaults to "MigrationInfos".</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="builder" /> or <paramref name="tableName" /> is null.</exception>
        /// <exception cref="EmptyStringException">Thrown when <paramref name="tableName" /> is an empty string.</exception>
        /// <exception cref="WhiteSpaceStringException">Thrown when <paramref name="tableName" /> contains only white space.</exception>
        public static FluentMappingBuilder MapMigrationInfo(this FluentMappingBuilder builder, string tableName = "MigrationInfos")
        {
            builder.MustNotBeNull(nameof(builder));
            tableName.MustNotBeNullOrWhiteSpace(nameof(tableName));

            builder.Entity <MigrationInfo>()
            .HasTableName(tableName)
            .Property(info => info.Id).IsIdentity().IsPrimaryKey()
            .Property(info => info.Name).HasLength(100).IsNullable(false)
            .Property(info => info.Version).HasLength(20).IsNullable(false);
            return(builder);
        }