示例#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);
        }
示例#2
0
 public EFUnitOfWork(EFOptions options, Action <LogLevel, string> logAction)
 {
     _options   = options;
     _dbFactory = new DbFactory(_options, logAction);
 }
示例#3
0
 public DbFactory(MultipleEFOptions multipleOptions, Action <LogLevel, string> logAction)
 {
     _multipleOptions = multipleOptions;
     _options         = _multipleOptions.FirstOrDefault(x => x.IsDefaultOption);
     _logAction       = logAction;
 }
示例#4
0
 public DbFactory(EFOptions options, Action <LogLevel, string> logAction)
 {
     _options   = options;
     _logAction = logAction;
 }
示例#5
0
 public EFUnitOfWorkModule(IConfigurationRoot jimuAppSettings) : base(jimuAppSettings)
 {
     _options    = JimuAppSettings.GetSection(typeof(EFOptions).Name).Get <EFOptions>();
     _mulOptions = JimuAppSettings.GetSection(typeof(MultipleEFOptions).Name).Get <MultipleEFOptions>();
 }
示例#6
0
 public EFUnitOfWorkDbContext(EFOptions options, Action <LogLevel, string> logAction) : base(new DbContextOptions <EFUnitOfWorkDbContext>())
 {
     _options       = options;
     _logAction     = logAction;
     _loggerFactory = new LoggerFactory();
 }