private void UpdateStrQuery() { if (_OrderFld == null) { return; } int i = 0; string tmpFilter; string TmpStr2; _strOrderAsc = string.Empty; _strOrderDesc = string.Empty; OrderInKey = false; foreach (FieldDef fld in td.KeyFields.Values) { if (object.ReferenceEquals(fld, _OrderFld)) { OrderInKey = true; break; } } int numKey = OrderInKey ? td.KeyFields.Count - 1 : td.KeyFields.Count; _CurrentKeyField = new FieldDef[numKey]; _ParamCurrentKeyField = new FieldParam[numKey]; foreach (FieldDef fld in td.KeyFields.Values) { if (!object.ReferenceEquals(fld, _OrderFld)) { _CurrentKeyField[i] = fld; _ParamCurrentKeyField[i++] = new FieldParam(fld); _strOrderAsc = string.Concat(_strOrderAsc, ",", fld._FieldName); _strOrderDesc = string.Concat(_strOrderDesc, ",", fld._FieldName, " DESC"); } } if (_Filter.Length > 0) { tmpFilter = string.Concat( " WHERE (", _Filter, ")"); WhereExist = true; } else { tmpFilter = string.Empty; WhereExist = false; } TmpStr2 = ((IRuleInitUI)_Entity).GetBrowseFilter(); if (TmpStr2.Length > 0) { if (WhereExist) { tmpFilter = string.Concat(tmpFilter, " AND (", TmpStr2, ")"); } else { WhereExist = true; tmpFilter = string.Concat(" WHERE (", TmpStr2, ")"); } } else { string SqlSelect, SqlCondition, SqlOrderBy; ((IRuleInitUI)_Entity).GetBrowseSql(out SqlSelect, out SqlCondition, out SqlOrderBy); if (SqlSelect.Length > 0) { if (SqlCondition.Length == 0) { strQuery = string.Concat("SELECT ", _OrderFld._FieldName, _strOrderAsc, " FROM (", SqlSelect, ") AS X", tmpFilter); } else { tmpFilter = string.Concat(" WHERE (", SqlCondition, ")"); WhereExist = true; strQuery = string.Concat("SELECT ", _OrderFld._FieldName, _strOrderAsc, " FROM (", SqlSelect, ") AS X", tmpFilter); } return; } } if (_OrderFld._dtlsa == null) { strQuery = string.Concat("SELECT ", _OrderFld._FieldName, _strOrderAsc, " FROM ", td._TableName, tmpFilter); } else { strQuery = string.Concat("SELECT ", _OrderFld._FieldName, _strOrderAsc, " FROM (SELECT (", _Entity.Dp .GetSqlCoalesceNoFormat( string.Concat("(", _OrderFld._dtlsa.GetSqlQuery(), ")"), _Entity.Dp .FormatSqlValue(_OrderFld.GetDataTypeDefault())), ") AS ", _OrderFld._FieldName, _strOrderAsc, " FROM ", td._TableName, tmpFilter, ") AS X"); } }