Ejemplo n.º 1
0
        /// <summary>
        /// 重写以获取是否开启延迟加载代理特性
        /// </summary>
        /// <returns></returns>
        public override bool LazyLoadingProxiesEnabled()
        {
            if (_serviceProvider == null)
            {
                IConfiguration configuration = Singleton <IConfiguration> .Instance;
                return(configuration["ESoftor:DbContexts:SqlServer:LazyLoadingProxiesEnabled"].CastTo(false));
            }
            ESoftorOptions          options        = _serviceProvider.GetESoftorOptions();
            ESoftorDbContextOptions contextOptions = options.GetDbContextOptions(typeof(DefaultDbContext));

            if (contextOptions == null)
            {
                throw new ESoftorException($"上下文“{typeof(DefaultDbContext)}”的配置信息不存在");
            }

            return(contextOptions.LazyLoadingProxiesEnabled);
        }
Ejemplo n.º 2
0
        public override string GetConnectionString()
        {
            if (_serviceProvider == null)
            {
                IConfiguration configuration = Singleton <IConfiguration> .Instance;
                string         str           = configuration["ESoftor:DbContexts:SqlServer:ConnectionString"]
                                               ?? configuration["ConnectionStrings:DefaultDbContext"];
                return(str);
            }
            ESoftorOptions          options        = _serviceProvider.GetESoftorOptions();
            ESoftorDbContextOptions contextOptions = options.GetDbContextOptions(typeof(DefaultDbContext));

            if (contextOptions == null)
            {
                throw new ESoftorException($"上下文“{typeof(DefaultDbContext)}”的配置信息不存在");
            }
            return(contextOptions.ConnectionString);
        }