/// <summary> /// 获取只取主键的SQL语句 /// </summary> internal string BuildKeyStringForRetrieve() { this._sqlString = SqlCommander.BuildForConditions(_conditions); string tempre = ""; //如果不能使用Where从句 if (_classMap.SuperClass == null && _sqlString == null) { tempre = this.GetSelectKeyClause(); } else { //如果未指定过滤条件,且_classMap.SuperClass !=null if (_sqlString == null) { tempre = GetSelectKeyClause() + " WHERE " + _classMap.StringForInherit; } //如果指定了过滤条件(_sqlString!= null) else { tempre = GetSelectKeyClause() + " WHERE " + _sqlString; } } //Order by if (this._orderList != null) { tempre += SelectCommander.GetOrderSql(_orderList, _classMap); } return(tempre); }
internal void BuildStringForRetrieve() { this._sqlString = SqlCommander.BuildForConditions(_conditions); //如果不能使用Where从句 if (_classMap.SuperClass == null && _sqlString == null) { _sqlString = GetSelectClause(); } else { //如果未指定过滤条件,且_classMap.SuperClass !=null if (_sqlString == null) { _sqlString = GetSelectClause() + " WHERE " + _classMap.StringForInherit; } //如果指定了过滤条件(_sqlString!= null) else { _sqlString = GetSelectClause() + " WHERE " + _sqlString; //且有父类 if (_classMap.SuperClass != null) { _sqlString += " AND " + _classMap.StringForInherit; } } } //Order by if (this._orderList != null) { this._sqlString += SelectCommander.GetOrderSql(_orderList, _classMap); } }
internal void BuildStringForDelete() { this._sqlString = _classMap.DeleteFromClause; string where = SqlCommander.BuildForConditions(this._conditions); if (where != null) { _sqlString += " WHERE " + where; } }
//构造Query的条件 返回string private string GetSqlForConditions() { string where = SqlCommander.BuildForConditions(this.m_Conditions); if (where == null) { return(" 1=1 " + this.whereClause); } else { return("( " + where + this.whereClause + " )"); } }
internal void BuildStringForUpdate() { string where = SqlCommander.BuildForConditions(this._conditions); this._sqlString = "UPDATE "; this._sqlString += this.classMap.RelationalDatabase.QuotationMarksStart + this.classMap.Table.Name + this.classMap.RelationalDatabase.QuotationMarksEnd; this._sqlString += " SET "; int i = 0; foreach (object key in this.m_ForUpdateCollection.Keys) { this._sqlString += this._classMap.RelationalDatabase.QuotationMarksStart + this._classMap.GetAttributeMap(key.ToString()).Column.Name + this._classMap.RelationalDatabase.QuotationMarksEnd + "="; this._sqlString += this._classMap.RelationalDatabase.GetStringParameter(key.ToString(), i); this._sqlString += ","; i++; } // //tintown added at 2005-3-22 添加对timestamp的更新 //由于在更新标准时不进行timestamp判断,所以不需要更新timestamp值,要不然,会导致事务中的同一表更新不成功。 // if(_classMap.TimestampAttribute!=null) // { // ColumnMap cm=_classMap.TimestampAttribute.Column ; // this._sqlString+=cm.Name+"="; // this._sqlString+=this._classMap.RelationalDatabase.GetStringParameter("Update"+cm.Name,i); // this._sqlString+=","; // } char[] chars = new char[] { ',' }; this._sqlString = this._sqlString.TrimEnd(chars); if (where != null) { _sqlString += " WHERE " + where; } }