/// <summary> /// /// </summary> /// <param name="type"></param> /// <param name="bDataBase"></param> /// <param name="bWithLock"></param> /// <param name="bNeedParams"></param> /// <param name="bNeedQueryProvider"></param> protected DMS(Type type, string bDataBase, bool bWithLock, bool bNeedParams, bool bNeedQueryProvider) { DMSFrameException.ThrowIfNull(type); this.DataType = type; this.CurrentType = type; TableMappingAttribute attribute = DMSExpression.GetTableMappingAttribute(type); this.TableExpressioin = DMSExpression.GetTableExpression(attribute.DMSDbType); this.ColumnsExpressioin = DMSExpression.GetColumnsExpression(attribute.DMSDbType); this.WhereExpressioin = DMSExpression.GetWhereExpression(attribute.DMSDbType); this.OrderByExpressioin = DMSExpression.GetOrderByExpression(attribute.DMSDbType); this.GroupByExpression = DMSExpression.GetGroupByExpression(attribute.DMSDbType); this.HavingExpression = DMSExpression.GetHavingExpression(attribute.DMSDbType); this.SplitExpression = DMSExpression.GetSplitExpression(attribute); this.Provider = DMSExpression.GetDbProvider(attribute.DMSDbType, attribute.ConfigName); this.dynamicParameters = new DynamicParameters(); DMSFrameException.ThrowIfNull(this.TableExpressioin, this.ColumnsExpressioin, this.WhereExpressioin, this.OrderByExpressioin, this.GroupByExpression, this.HavingExpression); if (!string.IsNullOrEmpty(bDataBase)) { this.TableExpressioin.bDataBase = bDataBase; DMSDataBase myDb = new DMSDataBase(bDataBase); this.TableExpressioin.Append <DMSDataBase, DMSDataBase>(q => myDb); } this.TableExpressioin.WithLock = bWithLock; this.ExcuteType = DMSExcuteType.SELECT; this.TableExpressioin.NeedParams = bNeedParams; this.ColumnsExpressioin.NeedParams = bNeedParams; this.WhereExpressioin.NeedParams = bNeedParams; this.OrderByExpressioin.NeedParams = bNeedParams; this.GroupByExpression.NeedParams = bNeedParams; this.HavingExpression.NeedParams = bNeedParams; this.TableExpressioin.SplitExpression = this.SplitExpression; this.ColumnsExpressioin.SplitExpression = this.SplitExpression; this.WhereExpressioin.SplitExpression = this.SplitExpression; this.OrderByExpressioin.SplitExpression = this.SplitExpression; this.GroupByExpression.SplitExpression = this.SplitExpression; this.HavingExpression.SplitExpression = this.SplitExpression; }
/// <summary> /// /// </summary> /// <param name="SplitPagerFlag"></param> /// <param name="PageIndex"></param> /// <param name="PageSize"></param> /// <param name="tableKey"></param> /// <param name="orderSql"></param> public virtual void AnalyzeExpressionPager(bool SplitPagerFlag, int PageIndex, int PageSize, string tableKey, string orderSql) { StringBuilder tempSql = new StringBuilder(resultSql.ToString()); resultSqlCount = new StringBuilder(); if (SplitPagerFlag && PageIndex != 1) { DMSFrameException.ThrowIfNull(string.IsNullOrEmpty(orderSql), "分页必须包含排序字段!"); } if (SplitPagerFlag) { bool flag = this.DMSFrame.Provider.ConstructPageSplitableSelectStatementForCount(resultSql.ToString(), ref resultSqlCount); if (!flag) { throw new DMSFrameException("获取Count查询出错!"); } } string splitSql; if (PageIndex == 1) { bool flag = this.DMSFrame.Provider.ConstructPageSplitableSelectStatementForFirstPage(resultSql.ToString(), PageSize, out splitSql); if (!flag) { throw new DMSFrameException("获取TOP查询出错!"); } this.resultSql = new StringBuilder(splitSql); } else { bool flag = this.DMSFrame.Provider.ConstructPageSplitableSelectStatement(resultSql.ToString(), this.MemberSql, PageIndex, PageSize, tableKey, out splitSql); if (!flag) { throw new DMSFrameException("获取TOP查询出错!"); } this.resultSql = new StringBuilder(splitSql); } }