Exemplo n.º 1
0
        public DbContext Create(out EFOptions options, string optionName = null)
        {
            options = null;
            if (string.IsNullOrEmpty(optionName) || optionName == _options?.OptionName)
            {
                options = _options;
            }
            else if (_multipleOptions != null && _multipleOptions.Any(x => x.OptionName == optionName))
            {
                options = _multipleOptions.FirstOrDefault(x => x.OptionName == optionName);
            }
            if (options == null)
            {
                throw new EFUnitOfWorkException("Options is null");
            }
            EFUnitOfWorkDbContext context = new EFUnitOfWorkDbContext(options, _logAction);

            return(context);
        }
Exemplo n.º 2
0
 public EFUnitOfWork(EFOptions options, Action <LogLevel, string> logAction)
 {
     _options   = options;
     _dbFactory = new DbFactory(_options, logAction);
 }
Exemplo n.º 3
0
 public DbFactory(MultipleEFOptions multipleOptions, Action <LogLevel, string> logAction)
 {
     _multipleOptions = multipleOptions;
     _options         = _multipleOptions.FirstOrDefault(x => x.IsDefaultOption);
     _logAction       = logAction;
 }
Exemplo n.º 4
0
 public DbFactory(EFOptions options, Action <LogLevel, string> logAction)
 {
     _options   = options;
     _logAction = logAction;
 }
Exemplo n.º 5
0
 public EFUnitOfWorkModule(IConfigurationRoot jimuAppSettings) : base(jimuAppSettings)
 {
     _options    = JimuAppSettings.GetSection(typeof(EFOptions).Name).Get <EFOptions>();
     _mulOptions = JimuAppSettings.GetSection(typeof(MultipleEFOptions).Name).Get <MultipleEFOptions>();
 }
Exemplo n.º 6
0
 public EFUnitOfWorkDbContext(EFOptions options, Action <LogLevel, string> logAction) : base(new DbContextOptions <EFUnitOfWorkDbContext>())
 {
     _options       = options;
     _logAction     = logAction;
     _loggerFactory = new LoggerFactory();
 }