Exemple #1
0
 public PublicKeyRepository(AuroraEntities context)
     : base(context)
 {
 }
Exemple #2
0
 public NetworkRepository(AuroraEntities context)
     : base(context)
 {
 }
 public UserFolderRepository(AuroraEntities context)
     : base(context)
 {
 }
Exemple #4
0
 public SettingRepository(AuroraEntities context)
     : base(context)
 {
 }
Exemple #5
0
 public UserMountRepository(AuroraEntities context)
     : base(context)
 {
 }
 public CredentialRepository(AuroraEntities context)
     : base(context)
 {
 }
Exemple #7
0
        public UnitOfWork(string connection, IContextService instance)
        {
            _logger = LoggerFactory.Create(opt =>
            {
                opt.AddFilter("Microsoft", LogLevel.Warning)
                .AddFilter("Microsoft.EntityFrameworkCore", LogLevel.Information)
                .AddFilter("System", LogLevel.Warning)
                .AddConsole();
            });

            switch (instance.InstanceType)
            {
            case InstanceContext.DeployedOrLocal:
            {
#if !RELEASE
                var builder = new DbContextOptionsBuilder <AuroraEntities>()
                              .UseSqlServer(connection);
                //.UseLoggerFactory(_logger)
                //.EnableSensitiveDataLogging();
#elif RELEASE
                var builder = new DbContextOptionsBuilder <AuroraEntities>()
                              .UseSqlServer(connection);
#endif
                _context = new AuroraEntities(builder.Options);
            }
            break;

            case InstanceContext.End2EndTest:
            case InstanceContext.IntegrationTest:
            case InstanceContext.UnitTest:
            {
#if !RELEASE
                var builder = new DbContextOptionsBuilder <AuroraEntities>()
                              .UseInMemoryDatabase(":InMemory:")
                              .UseLoggerFactory(_logger)
                              .EnableSensitiveDataLogging();
#elif RELEASE
                var builder = new DbContextOptionsBuilder <AuroraEntities>()
                              .UseInMemoryDatabase(":InMemory:");
#endif
                _context = new AuroraEntities(builder.Options);
            }
            break;

            default:
                throw new NotImplementedException();
            }

            _context.ChangeTracker.LazyLoadingEnabled  = false;
            _context.ChangeTracker.CascadeDeleteTiming = CascadeTiming.Immediate;

            InstanceType = instance.InstanceType;

            Credentials = new CredentialRepository(_context);
            Networks    = new NetworkRepository(_context);
            PrivateKeys = new PrivateKeyRepository(_context);
            PublicKeys  = new PublicKeyRepository(_context);
            Settings    = new SettingRepository(_context);
            UserFiles   = new UserFileRepository(_context);
            UserFolders = new UserFolderRepository(_context);
            UserMounts  = new UserMountRepository(_context);
            Users       = new UserRepository(_context);
        }