/// <summary>
        /// 获取实体(异步方式)
        /// </summary>
        /// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
        /// <param name="dict">参数的名/值集合</param>
        /// <returns></returns>
        public virtual async Task <CollectionPagingRulesEntity> GetEntityAsync(string strWhere, Dictionary <string, object> dict = null)
        {
            CollectionPagingRulesEntity obj = null;
            string strSQL = "select top 1 * from CollectionPagingRules where 1=1 " + strWhere;

            using (NullableDataReader reader = await Task.Run(() => _DB.GetDataReader(strSQL, dict)))
            {
                if (reader.Read())
                {
                    obj = GetEntityFromrdr(reader);
                }
            }
            return(obj);
        }
 /// <summary>
 /// 把实体类转换成键/值对集合
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="dict"></param>
 private static void GetParameters(CollectionPagingRulesEntity entity, Dictionary <string, object> dict)
 {
     dict.Add("PagingRuleID", entity.PagingRuleID);
     dict.Add("ItemID", entity.ItemID);
     dict.Add("RuleType", entity.RuleType);
     dict.Add("PagingType", entity.PagingType);
     dict.Add("PagingBeginCode", entity.PagingBeginCode);
     dict.Add("PagingEndCode", entity.PagingEndCode);
     dict.Add("LinkBeginCode", entity.LinkBeginCode);
     dict.Add("LinkEndCode", entity.LinkEndCode);
     dict.Add("DesignatedUrl", entity.DesignatedUrl);
     dict.Add("ScopeBegin", entity.ScopeBegin);
     dict.Add("ScopeEnd", entity.ScopeEnd);
     dict.Add("PagingUrlList", entity.PagingUrlList);
     dict.Add("CorrelationRuleId", entity.CorrelationRuleId);
 }
        /// <summary>
        /// 增加一条记录,返回新的ID号。需要有一个单一主键,并且开启有标识符属性(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <int> InsertAsync(CollectionPagingRulesEntity entity)
        {
            if (entity.PagingRuleID <= 0)
            {
                entity.PagingRuleID = GetNewID();
            }
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);

            string strSQL = "insert into CollectionPagingRules (" +
                            "PagingRuleID," +
                            "ItemID," +
                            "RuleType," +
                            "PagingType," +
                            "PagingBeginCode," +
                            "PagingEndCode," +
                            "LinkBeginCode," +
                            "LinkEndCode," +
                            "DesignatedUrl," +
                            "ScopeBegin," +
                            "ScopeEnd," +
                            "PagingUrlList," +
                            "CorrelationRuleId) " +
                            "values(" +
                            "@PagingRuleID," +
                            "@ItemID," +
                            "@RuleType," +
                            "@PagingType," +
                            "@PagingBeginCode," +
                            "@PagingEndCode," +
                            "@LinkBeginCode," +
                            "@LinkEndCode," +
                            "@DesignatedUrl," +
                            "@ScopeBegin," +
                            "@ScopeEnd," +
                            "@PagingUrlList," +
                            "@CorrelationRuleId)";

            if (await Task.Run(() => _DB.ExeSQLResult(strSQL, dict)))
            {
                return(DataConverter.CLng(entity.PagingRuleID));
            }
            return(-1);
        }
        /// <summary>
        /// 通过数据读取器生成实体类
        /// </summary>
        /// <param name="rdr"></param>
        /// <returns></returns>
        private static CollectionPagingRulesEntity GetEntityFromrdr(NullableDataReader rdr)
        {
            CollectionPagingRulesEntity info = new CollectionPagingRulesEntity();

            info.PagingRuleID      = rdr.GetInt32("PagingRuleID");
            info.ItemID            = rdr.GetInt32("ItemID");
            info.RuleType          = rdr.GetInt32("RuleType");
            info.PagingType        = rdr.GetInt32("PagingType");
            info.PagingBeginCode   = rdr.GetString("PagingBeginCode");
            info.PagingEndCode     = rdr.GetString("PagingEndCode");
            info.LinkBeginCode     = rdr.GetString("LinkBeginCode");
            info.LinkEndCode       = rdr.GetString("LinkEndCode");
            info.DesignatedUrl     = rdr.GetString("DesignatedUrl");
            info.ScopeBegin        = rdr.GetInt32("ScopeBegin");
            info.ScopeEnd          = rdr.GetInt32("ScopeEnd");
            info.PagingUrlList     = rdr.GetString("PagingUrlList");
            info.CorrelationRuleId = rdr.GetInt32("CorrelationRuleId");
            return(info);
        }
        /// <summary>
        /// 增加一条记录
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual bool Add(CollectionPagingRulesEntity entity)
        {
            if (entity.PagingRuleID <= 0)
            {
                entity.PagingRuleID = GetNewID();
            }
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);

            string strSQL = "insert into CollectionPagingRules (" +
                            "PagingRuleID," +
                            "ItemID," +
                            "RuleType," +
                            "PagingType," +
                            "PagingBeginCode," +
                            "PagingEndCode," +
                            "LinkBeginCode," +
                            "LinkEndCode," +
                            "DesignatedUrl," +
                            "ScopeBegin," +
                            "ScopeEnd," +
                            "PagingUrlList," +
                            "CorrelationRuleId) " +
                            "values(" +
                            "@PagingRuleID," +
                            "@ItemID," +
                            "@RuleType," +
                            "@PagingType," +
                            "@PagingBeginCode," +
                            "@PagingEndCode," +
                            "@LinkBeginCode," +
                            "@LinkEndCode," +
                            "@DesignatedUrl," +
                            "@ScopeBegin," +
                            "@ScopeEnd," +
                            "@PagingUrlList," +
                            "@CorrelationRuleId)";

            return(_DB.ExeSQLResult(strSQL, dict));
        }
        /// <summary>
        /// 更新一条记录(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <bool> UpdateAsync(CollectionPagingRulesEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);
            string strSQL = "Update CollectionPagingRules SET " +
                            "ItemID = @ItemID," +
                            "RuleType = @RuleType," +
                            "PagingType = @PagingType," +
                            "PagingBeginCode = @PagingBeginCode," +
                            "PagingEndCode = @PagingEndCode," +
                            "LinkBeginCode = @LinkBeginCode," +
                            "LinkEndCode = @LinkEndCode," +
                            "DesignatedUrl = @DesignatedUrl," +
                            "ScopeBegin = @ScopeBegin," +
                            "ScopeEnd = @ScopeEnd," +
                            "PagingUrlList = @PagingUrlList," +
                            "CorrelationRuleId = @CorrelationRuleId" +
                            " WHERE " +

                            "PagingRuleID = @PagingRuleID";

            return(await Task.Run(() => _DB.ExeSQLResult(strSQL, dict)));
        }
 /// <summary>
 /// 增加或更新一条记录(异步方式)
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual async Task <bool> AddOrUpdateAsync(CollectionPagingRulesEntity entity, bool IsSave)
 {
     return(IsSave ? await AddAsync(entity) : await UpdateAsync(entity));
 }
 /// <summary>
 /// 增加或更新一条记录
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual bool AddOrUpdate(CollectionPagingRulesEntity entity, bool IsSave)
 {
     return(IsSave ? Add(entity) : Update(entity));
 }