Beispiel #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);
        }
Beispiel #2
0
 public DbFactory(MultipleEFOptions multipleOptions, Action <LogLevel, string> logAction)
 {
     _multipleOptions = multipleOptions;
     _options         = _multipleOptions.FirstOrDefault(x => x.IsDefaultOption);
     _logAction       = logAction;
 }