Esempio n. 1
0
        public static IServiceCollection AddIntegrationEventLogContext(this IServiceCollection services, Action <IntegrationEventLogContextOptions> setupAction)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            if (setupAction == null)
            {
                throw new ArgumentNullException(nameof(setupAction));
            }
            services.Configure <IntegrationEventLogContextOptions>(setupAction);
            var options = new IntegrationEventLogContextOptions();

            setupAction.Invoke(options);
            services.AddSingleton(options);
            services.AddDbContext <IntegrationEventLogContext>(builder =>
            {
                options.ConfigureDbContext?.Invoke(builder);
            });
            return(services);
        }
 public IntegrationEventLogContext(DbContextOptions <IntegrationEventLogContext> options, IntegrationEventLogContextOptions contextOptions)
     : base(options)
 {
     _contextOptions = contextOptions ?? throw new ArgumentException(nameof(contextOptions));
 }
 public static void ConfigureIntegrationEventLogContext(this ModelBuilder @this, IntegrationEventLogContextOptions options)
 {
     @this.Entity <IntegrationEventLogEntry>(entity =>
     {
         var schema = string.IsNullOrEmpty(options.DefaultSchema) ? "dbo" : options.DefaultSchema;
         entity.ToTable("IntegrationEvents", schema);
         entity.HasKey(e => e.EventId);
         entity.Property(e => e.EventId).IsRequired();
         entity.Property(e => e.Content).IsRequired();
         entity.Property(e => e.CreationTime).IsRequired();
         entity.Property(e => e.State).IsRequired();
         entity.Property(e => e.TimesSent).IsRequired();
         entity.Property(e => e.EventTypeFullName).HasMaxLength(400).IsRequired();
     });
 }