Exemple #1
0
        public override TransportationContext CreateContext(SqlCeTestStore testStore, Action <ModelBuilder> onModelCreating)
        {
            var optionsBuilder = new DbContextOptionsBuilder()
                                 .UseSqlCe(testStore.Connection, b => b.ApplyConfiguration().CommandTimeout(300))
                                 .EnableSensitiveDataLogging()
                                 .UseInternalServiceProvider(BuildServiceProvider(onModelCreating));

            var context = new TransportationContext(optionsBuilder.Options);

            context.Database.UseTransaction(testStore.Transaction);
            return(context);
        }
        public override SqliteTestStore CreateTestStore(Action <ModelBuilder> onModelCreating)
        => SqliteTestStore.GetOrCreateShared(DatabaseName, false, true, () =>
        {
            var optionsBuilder = new DbContextOptionsBuilder()
                                 .UseSqlite(SqliteTestStore.CreateConnectionString(DatabaseName))
                                 .EnableSensitiveDataLogging()
                                 .UseInternalServiceProvider(BuildServiceProvider(onModelCreating));

            using (var context = new TransportationContext(optionsBuilder.Options))
            {
                context.Database.EnsureClean();
                context.Seed();
            }
        });
Exemple #3
0
        public override SqlCeTestStore CreateTestStore(Action <ModelBuilder> onModelCreating)
        => SqlCeTestStore.GetOrCreateShared(DatabaseName, () =>
        {
            var optionsBuilder = new DbContextOptionsBuilder()
                                 .UseSqlCe(_connectionString, b => b.ApplyConfiguration().CommandTimeout(300))
                                 .EnableSensitiveDataLogging()
                                 .UseInternalServiceProvider(BuildServiceProvider(onModelCreating));

            using (var context = new TransportationContext(optionsBuilder.Options))
            {
                context.Database.EnsureCreated();
                context.Seed();
            }
        });
Exemple #4
0
        protected virtual void OnModelCreating(ModelBuilder modelBuilder)
        {
            TransportationContext.OnModelCreatingBase(modelBuilder);

            modelBuilder.Entity <Vehicle>(eb =>
            {
                eb.HasDiscriminator <string>("Discriminator");
                eb.Property <string>("Discriminator").HasColumnName("Discriminator");
                eb.ToTable("Vehicles");
            });

            modelBuilder.Entity <Engine>().ToTable("Vehicles");
            modelBuilder.Entity <Operator>().ToTable("Vehicles");
            modelBuilder.Entity <FuelTank>().ToTable("Vehicles");
        }
Exemple #5
0
 /// <summary>
 /// The constructor accepts a database context instance and initializes the entity set variable
 /// </summary>
 /// <param name="context"></param>
 public GenericRepository(TransportationContext context)
 {
     this.context = context;
     this.dbSet   = context.Set <TEntity>();
 }
Exemple #6
0
 public ComposicaoVagaoRepository(TransportationContext context) : base(context)
 {
 }
Exemple #7
0
 public UnitOfWork(TransportationContext context)
 {
     _context  = context;
     _disposed = false;
 }
Exemple #8
0
 public TremRepository(TransportationContext context) : base(context)
 {
 }
Exemple #9
0
 public SerieVagaoRepository(TransportationContext context) : base(context)
 {
 }
Exemple #10
0
 public Repository(TransportationContext context)
 {
     Db    = context;
     DbSet = Db.Set <TEntity>();
 }
Exemple #11
0
 public FerroviaRepository(TransportationContext context)
     : base(context)
 {
 }