/// <summary>
        /// 添加 <see cref="ILoggerProvider"/>
        /// </summary>
        /// <param name="options"></param>
        /// <param name="provider"></param>
        /// <returns></returns>
        public static RepositoryOptions UseLogger(this RepositoryOptions options, ILoggerProvider provider = null)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (options.LoggerFactory == null)
            {
                options.LoggerFactory = new LoggerFactory();
            }
            if (provider == null)
            {
                options.LoggerFactory.AddProvider(new EFLoggerProvider());
            }
            else
            {
                options.LoggerFactory.AddProvider(provider);
            }
            return(options);
        }
Ejemplo n.º 2
0
 public CommonDbContext(IOptions <RepositoryOptions> optionsAccessor)
 {
     _options = optionsAccessor.Value;
 }