/// <summary>
        /// 动态聚组查询获取数据
        /// </summary>
        /// <param name="baseRule"></param>
        /// <param name="setting"></param>
        /// <param name="parInfos"></param>
        /// <param name="parValues"></param>
        /// <returns></returns>
        public System.Data.DataSet GetDynamicGroupQueryData(MB.Util.Model.DynamicGroupSetting setting, QueryParameterInfo[] parInfos, params object[] parValues)
        {
            MB.Orm.Mapping.QueryParameterMappings queryMappings = null;
            if (!string.IsNullOrEmpty(setting.EntityInfos.MainEntity.Alias))
            {
                queryMappings = new Orm.Mapping.QueryParameterMappings(setting.EntityInfos.MainEntity.Alias);
            }
            else
            {
                queryMappings = new Orm.Mapping.QueryParameterMappings(setting.EntityInfos.MainEntity.Name);
            }

            string   sqlFilter = MB.Orm.DbSql.SqlShareHelper.Instance.QueryParametersToSqlString(queryMappings, parInfos);
            Database db        = MB.Orm.Persistence.DatabaseHelper.CreateDatabase();

            MB.Orm.Persistence.PersistenceManagerHelper persitence = MB.Orm.Persistence.PersistenceManagerHelper.NewInstance;
            var       sql   = MB.Orm.DbSql.DynamicGroupBuilder.DynamicGroupBuilderFactory.CreateQueryBuilder(setting).BuildDynamicQuery(sqlFilter);
            DbCommand dbCmd = persitence.GetSqlStringCommand(db, sql);


            DataSet ds = null;

            try
            {
                MB.Util.TraceEx.Write("正在执行:" + MB.Orm.Persistence.DbCommandExecuteTrack.Instance.CommandToTrackMessage(db, dbCmd));

                ds = new DatabaseExecuteHelper(_QueryBehavior).ExecuteDataSet(db, dbCmd);
            }
            catch (Exception ex)
            {
                throw new MB.RuleBase.Exceptions.DatabaseExecuteException("GetDynamicGroupQueryData 出错!", ex);
            }
            return(ds);
        }
        /// <summary>
        /// 通过主键获取对应明细的数据。
        /// </summary>
        /// <param name="baseRule">指定操作的业务类</param>
        /// <param name="dataInDocType">指定的数据类型</param>
        /// <param name="mainKeyValue">主键</param>
        /// <returns></returns>
        public System.Data.DataSet GetObjectsByForeingKeyAsDs(IBaseRule baseRule, object dataInDocType, object mainKeyValue)
        {
            ObjectDataMappingAttribute mappingAtt = AttributeConfigHelper.Instance.GetObjectDataMappingAttribute(dataInDocType);

            if (mappingAtt == null)
            {
                throw new MB.RuleBase.Exceptions.RequireConfigDataMappingException(dataInDocType);
            }

            Database db = MB.Orm.Persistence.DatabaseHelper.CreateDatabase();

            System.Data.Common.DbCommand[] cmds = MB.Orm.Persistence.PersistenceManagerHelper.NewInstance.CreateDbCommandByXml(db,
                                                                                                                               mappingAtt.MappingXmlFileName, MB.Orm.Mapping.Xml.XmlSqlMappingInfo.SQL_GET_BY_FOREING_KEY,
                                                                                                                               mainKeyValue);

            if (cmds.Length != 1)
            {
                throw new MB.RuleBase.Exceptions.SelectSqlXmlConfigException(mappingAtt.MappingXmlFileName, MB.Orm.Mapping.Xml.XmlSqlMappingInfo.SQL_GET_BY_FOREING_KEY);
            }
            System.Data.Common.DbCommand cmd = cmds[0];
            DataSet ds = null;

            try {
                string cmdMsg = MB.Orm.Persistence.DbCommandExecuteTrack.Instance.CommandToTrackMessage(db, cmd);
                MB.Util.TraceEx.Write("正在执行:" + cmdMsg);
                ds = new DatabaseExecuteHelper(_QueryBehavior).ExecuteDataSet(db, cmd);
            }
            catch (Exception ex) {
                throw new MB.RuleBase.Exceptions.DatabaseExecuteException("GetObjectsByForeingKey 出错!", ex);
            }
            return(ds);
        }
        /// <summary>
        /// 根据数据类型和过滤条件返回需要的数据。
        /// </summary>
        /// <param name="baseRule">指定操作的业务类。</param>
        /// <param name="dataInDocType">指定的数据类型。</param>
        /// <param name="whereFilters">过滤条件</param>
        /// <param name="otherParamValues">其它附加的过滤条件</param>
        /// <returns>满足条件的DataSet 类型数据</returns>
        public System.Data.DataSet GetObjectAsDataSet(IBaseQueryRule baseRule, object dataInDocType, QueryParameterInfo[] parInfos, params object[] parValues)
        {
            ObjectDataMappingAttribute mappingAtt = AttributeConfigHelper.Instance.GetObjectDataMappingAttribute(dataInDocType);

            if (mappingAtt == null)
            {
                throw new MB.RuleBase.Exceptions.RequireConfigDataMappingException(dataInDocType);
            }

            string sqlName = string.IsNullOrEmpty(mappingAtt.XmlCfgSelectSqlName) ? MB.Orm.Mapping.Xml.XmlSqlMappingInfo.SQL_SELECT_OBJECT : mappingAtt.XmlCfgSelectSqlName;

            MB.Orm.Mapping.QueryParameterMappings queryMappings = baseRule.QueryParamMapping;
            if (queryMappings == null)
            {
                queryMappings = MB.Orm.Mapping.Xml.SqlConfigHelper.Instance.GetSqlQueryParamMappings(mappingAtt.MappingXmlFileName, sqlName);
            }

            string sqlFilter = MB.Orm.DbSql.SqlShareHelper.Instance.QueryParametersToSqlString(queryMappings, parInfos);

            Database db = MB.Orm.Persistence.DatabaseHelper.CreateDatabase();

            ArrayList paramValues = new ArrayList();

            if (parValues != null && parValues.Length > 0)
            {
                foreach (object v in parValues)
                {
                    paramValues.Add(v);
                }
            }
            paramValues.Add(sqlFilter);
            System.Data.Common.DbCommand[] cmds = MB.Orm.Persistence.PersistenceManagerHelper.NewInstance.CreateDbCommandByXml(db,
                                                                                                                               mappingAtt.MappingXmlFileName, sqlName, paramValues.ToArray());

            if (cmds.Length != 1)
            {
                throw new MB.RuleBase.Exceptions.SelectSqlXmlConfigException(mappingAtt.MappingXmlFileName, sqlName);
            }

            System.Data.Common.DbCommand cmd = cmds[0];

            DataSet ds = null;

            try {
                MB.Util.TraceEx.Write("正在执行:" + MB.Orm.Persistence.DbCommandExecuteTrack.Instance.CommandToTrackMessage(db, cmd));

                ds = new DatabaseExecuteHelper(_QueryBehavior).ExecuteDataSet(db, cmd);
            }
            catch (Exception ex) {
                throw new MB.RuleBase.Exceptions.DatabaseExecuteException("GetObjectAsDataSet 出错!", ex);
            }
            return(ds);
        }
        /// <summary>
        /// 通过Xml 配置的语句获取数据集。
        /// </summary>
        /// <param name="transaction"></param>
        /// <param name="xmlFileName">SQL 语句所在的Xml 文件名称</param>
        /// <param name="sqlName">SQL 语句定义的名称</param>
        /// <param name="parValues">SQL 参数值</param>
        /// <returns>指定类型的集合类</returns>
        public DataSet GetDataSetByXml(Database db, DbTransaction transaction, string xmlFileName, string sqlName, params object[] parValues)
        {
            MB.Util.TraceEx.Write("开始执行  MB.Orm.Persistence.PersistenceManagerHelper.NewInstance.CreateDbCommandByXml ");

            System.Data.Common.DbCommand[] cmds = null;
            try {
                if (_PersistenceManager == null)
                {
                    _PersistenceManager = new PersistenceManagerHelper(_CommandTextFormatValues);
                }

                cmds = _PersistenceManager.CreateDbCommandByXml(db, xmlFileName, sqlName, parValues);
            }
            catch (Exception exx) {
                throw new MB.Util.APPException(exx);
            }
            if (cmds.Length != 1)
            {
                throw new MB.RuleBase.Exceptions.SelectSqlXmlConfigException(xmlFileName, sqlName);
            }

            System.Data.Common.DbCommand cmd = cmds[0];

            string cmdMsg = MB.Orm.Persistence.DbCommandExecuteTrack.Instance.CommandToTrackMessage(db, cmd);

            MB.Util.TraceEx.Write("正在执行:" + cmdMsg);
            DataSet ds = new DataSet();

            try {
                using (new Util.MethodTraceWithTime(true, cmdMsg))
                {
                    ds = new DatabaseExecuteHelper(_QueryBehavior).ExecuteDataSet(db, cmd, transaction);
                }
            }
            catch (Exception ex) {
                throw new MB.RuleBase.Exceptions.DatabaseExecuteException("执行GetDataSetByXml 出错!", ex);
            }
            finally {
                foreach (DbCommand td in cmds)
                {
                    td.Dispose();
                }
            }
            return(ds);
        }
 /// <summary>
 /// 对象提交封装处理。
 /// </summary>
 public ObjectSubmitHelper()
 {
     _DbExexuteHelper = new DatabaseExecuteHelper();
 }