Example #1
0
 private void ValidateApplyItemSection(ApplyItemCollection applyItems)
 {
     if (applyItems == null || applyItems.Count == 0)
     {
         throw new ConfigurationErrorsException("当前应用程序的 EF 读写分离服务配置文件定义有误,不包含任何的读写分离数据库连接配置映射项。");
     }
 }
Example #2
0
        /// <summary>
        /// 根据 EF 数据库上下文类型获取当前应用程序的 EF 读写分离服务配置文件中其所对应的 <see cref="ApplyItemElement"/> 对象。
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public ApplyItemElement GetApplyItem(System.Data.Entity.DbContext context)
        {
            ApplyItemCollection applyItems = this.ApplyItems;

            this.ValidateApplyItemSection(applyItems);
            return(applyItems.GetApplyItem(context));
        }
Example #3
0
        /// <summary>
        /// 根据 EF 数据库上下文对象获取当前应用程序的 EF 读写分离服务配置文件中其所对应的 <see cref="ApplyItemElement"/> 对象。
        /// </summary>
        /// <param name="contextType"></param>
        /// <returns></returns>
        public ApplyItemElement GetApplyItem(Type contextType)
        {
            ApplyItemCollection applyItems = this.ApplyItems;

            this.ValidateApplyItemSection(applyItems);
            return(applyItems.GetApplyItem(contextType));
        }
 private void ValidateApplyItemSection(ApplyItemCollection applyItems)
 {
     if (applyItems == null || applyItems.Count == 0)
     {
         throw new ConfigurationErrorsException("当前应用程序的 EF 读写分离服务配置文件定义有误,不包含任何的读写分离数据库连接配置映射项。");
     }
 }