private static FluentMappingBuilder RegisterThemeAggregates(this FluentMappingBuilder builder)
        {
            builder.Entity <ThemeAggregates::Theme>()
            .HasSchemaName(ThemeAggregatesSchema)
            .HasPrimaryKey(x => x.Id);

            builder.Entity <ThemeAggregates::Theme.InvalidCategory>()
            .HasSchemaName(ThemeAggregatesSchema)
            .HasPrimaryKey(x => new { x.ThemeId, x.CategoryId });

            builder.Entity <ThemeAggregates::Order>()
            .HasSchemaName(ThemeAggregatesSchema)
            .HasPrimaryKey(x => x.Id);

            builder.Entity <ThemeAggregates::Order.OrderTheme>()
            .HasSchemaName(ThemeAggregatesSchema)
            .HasPrimaryKey(x => new { x.OrderId, x.ThemeId });

            builder.Entity <ThemeAggregates::Project>()
            .HasSchemaName(ThemeAggregatesSchema)
            .HasPrimaryKey(x => x.Id);

            builder.Entity <ThemeAggregates::Project.ProjectDefaultTheme>()
            .HasSchemaName(ThemeAggregatesSchema)
            .HasPrimaryKey(x => new { x.ProjectId, x.ThemeId });

            return(builder);
        }
 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 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 RegisterFirmAggregates(this FluentMappingBuilder builder)
        {
            builder.Entity <FirmAggregates::Firm>()
            .HasSchemaName(FirmAggregatesSchema)
            .HasPrimaryKey(x => x.Id);

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

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

            builder.Entity <FirmAggregates::Order.FirmOrganizationUnitMismatch>()
            .HasSchemaName(FirmAggregatesSchema)
            .HasPrimaryKey(x => x.OrderId);

            builder.Entity <FirmAggregates::Order.InvalidFirm>()
            .HasSchemaName(FirmAggregatesSchema)
            .HasPrimaryKey(x => x.OrderId);

            builder.Entity <FirmAggregates::Order.PartnerPosition>()
            .HasSchemaName(FirmAggregatesSchema)
            .HasPrimaryKey(x => new { x.DestinationFirmAddressId, x.OrderPositionId })
            .HasIndex(x => x.OrderId, x => x.DestinationFirmId)
            .HasIndex(x => x.DestinationFirmId, x => x.OrderId);

            builder.Entity <FirmAggregates::Order.PremiumPartnerPosition>()
            .HasSchemaName(FirmAggregatesSchema)
            .HasPrimaryKey(x => x.OrderId);

            builder.Entity <FirmAggregates::Order.FmcgCutoutPosition>()
            .HasSchemaName(FirmAggregatesSchema)
            .HasPrimaryKey(x => x.OrderId);

            builder.Entity <FirmAggregates::Order.AddressAdvertisementNonOnTheMap>()
            .HasSchemaName(FirmAggregatesSchema)
            .HasPrimaryKey(x => new { x.OrderId, x.OrderPositionId, x.PositionId, x.AddressId });

            // таблица маленькая, нет PK
            builder.Entity <FirmAggregates::Order.MissingValidPartnerFirmAddresses>()
            .HasSchemaName(FirmAggregatesSchema)
            .HasIndex(x => x.OrderId);

            builder.Entity <FirmAggregates::Order.InvalidFirmAddress>()
            .HasSchemaName(FirmAggregatesSchema)
            .HasPrimaryKey(x => new { x.OrderId, x.OrderPositionId, x.PositionId, x.FirmAddressId });

            builder.Entity <FirmAggregates::Order.InvalidCategory>()
            .HasSchemaName(FirmAggregatesSchema)
            .HasPrimaryKey(x => new { x.OrderId, x.OrderPositionId, x.PositionId, x.CategoryId });

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

            return(builder);
        }
Exemple #5
0
        public static FluentMappingBuilder ApplyMappingBuilder <TEntity>(this FluentMappingBuilder fluentMappingBuilder,
                                                                         EntityMapBuilder <TEntity> entityTypeBuilder)
        {
            entityTypeBuilder.Map(fluentMappingBuilder);

            return(fluentMappingBuilder);
        }
Exemple #6
0
        /// <summary>
        /// Add and configure any of the middleware
        /// </summary>
        /// <param name="services">Collection of service descriptors</param>
        /// <param name="configuration">Configuration of the application</param>
        public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
        {
            var mappingBuilder = new FluentMappingBuilder(NopDataConnection.AdditionalSchema);

            //find database mapping configuration by other assemblies
            var typeFinder         = new AppDomainTypeFinder();
            var typeConfigurations = typeFinder.FindClassesOfType <IMappingConfiguration>().ToList();

            foreach (var typeConfiguration in typeConfigurations)
            {
                var mappingConfiguration = (IMappingConfiguration)Activator.CreateInstance(typeConfiguration);
                mappingConfiguration.ApplyConfiguration(mappingBuilder);
            }

            //further actions are performed only when the database is installed
            if (!DataSettingsManager.DatabaseIsInstalled)
            {
                return;
            }

            DataConnection.DefaultSettings = Singleton <DataSettings> .Instance;

            MappingSchema.Default.SetConvertExpression <string, Guid>(strGuid => new Guid(strGuid));

            services
            // add common FluentMigrator services
            .AddFluentMigratorCore()
            .ConfigureRunner(rb => rb.SetServer()
                             .WithVersionTable(new MigrationVersionInfo())
                             // define the assembly containing the migrations
                             .ScanIn(typeConfigurations.Select(p => p.Assembly).Distinct().ToArray()).For.Migrations());
        }
        public BaseSqlJobQueuePurger(IJobQueueDataConnectionFactory jobQueueConnectionFactory,
                                     ISqlDbJobQueueTableConfiguration tableConfig)
        {
            _jobQueueConnectionFactory = jobQueueConnectionFactory;

            _mappingSchema = Mapping.BuildMappingSchema(tableConfig);
        }
Exemple #8
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);
 }
        public BudgetLogMappingSchema()
        {
            FluentMappingBuilder b = GetFluentMappingBuilder();

            Configure <Transaction>(b, "Transactions");
            Configure <Forecast>(b, "Forecasts");
        }
        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);
        }
        /// <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);
        }
 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);
 }
 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);
 }
Exemple #14
0
        private static FluentMappingBuilder RegisterWebApp(this FluentMappingBuilder builder)
        {
            builder.Entity <Lock>()
            .HasSchemaName(WebAppSchema)
            .HasPrimaryKey(x => x.Id);

            return(builder);
        }
Exemple #15
0
 public override void Map(FluentMappingBuilder builder)
 {
     builder.Entity <Shortcut>()
     .HasTableName(nameof(Shortcut))
     .HasSchemaName(TableSchemaConst.Dbo)
     .HasIdentity(x => x.Id)
     .HasPrimaryKey(x => x.Id);
 }
Exemple #16
0
        public BaseSqlJobQueueAdder(IJobQueueDataConnectionFactory jobQueueDataConnectionFactory,
                                    IJobAdderQueueTableResolver tableResolver)
        {
            _jobQueueConnectionFactory = jobQueueDataConnectionFactory;

            _mappingSchema = MappingSchema.Default.GetFluentMappingBuilder();
            _tableResolver = tableResolver;
        }
Exemple #17
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 RegisterSystemAggregates(this FluentMappingBuilder builder)
        {
            builder.Entity <SystemAggregates::SystemStatus>()
            .HasSchemaName(SystemAggregatesSchema)
            .HasPrimaryKey(x => x.Id);

            return(builder);
        }
        protected SqlServerDataConnection(LinqToDbConnectionOptions <CaminoDataConnection> options) : base(options)
        {
            var mappingSchema = new MappingSchema();

            FluentMapBuilder = mappingSchema.GetFluentMappingBuilder();
            AddMappingSchema(mappingSchema);
            OnMappingSchemaCreating();
        }
Exemple #20
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");
 }
        private static FluentMappingBuilder RegisterEvents(this FluentMappingBuilder builder)
        {
            builder.Entity <EventRecord>()
            .HasSchemaName(EventsSchema)
            .HasPrimaryKey(x => x.Id)
            .HasIdentity(x => x.Id);

            return(builder);
        }
Exemple #22
0
        public static FluentMappingBuilder ApplyMappingBuilder <T>(this FluentMappingBuilder fluentMappingBuilder)
            where T : EntityMapBuilder, new()
        {
            var entityTypeBuilder = new T();

            entityTypeBuilder.Map(fluentMappingBuilder);

            return(fluentMappingBuilder);
        }
Exemple #23
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);
 }
Exemple #24
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);
 }
Exemple #25
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);
 }
 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);
 }
Exemple #27
0
        public BaseSqlJobQueueManager(IJobQueueDataConnectionFactory jobQueueConnectionFactory,
                                      ISqlDbJobQueueTableConfiguration jobQueueTableConfiguration, IJobTypeResolver typeResolver)
        {
            _jobQueueConnectionFactory = jobQueueConnectionFactory;

            _jobQueueTableConfiguration = jobQueueTableConfiguration;
            _typeResolver = typeResolver;

            _mappingSchema = MappingSchema.Default.GetFluentMappingBuilder();
        }
Exemple #28
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);
 }
Exemple #29
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);
 }
Exemple #30
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);
 }