コード例 #1
0
        public UnitTest1()
        {
            string connectionString = @"Data Source=OTAVIO\SQLEXPRESS;Initial Catalog=IgrejaDB;Integrated Security=True";

            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkSqlServer()
                                  //.AddDbContext<IgrejaDbContext>(options => options.UseSqlServer(connectionString))
                                  .AddTransient <IUsuarioRepository, UsuarioRepository>()
                                  .BuildServiceProvider();

            var builder = new DbContextOptionsBuilder <IgrejaDbContext>();

            builder.UseSqlServer(connectionString).UseInternalServiceProvider(serviceProvider);

            _context = new IgrejaDbContext(builder.Options);
            //serviceProvider.AddTransient<IUsuarioRepository, UsuarioRepository>();
        }
コード例 #2
0
 public Repository(IgrejaDbContext context)
 {
     _context = context;
 }
コード例 #3
0
 public UsuarioRepository(IgrejaDbContext context) : base(context)
 {
 }