trunk/src/LythumOSL.Core/Data/Database.cs
/// <summary>
/// Crafts update query with cleanup, without checking DataRow::RowState
/// </summary>
/// <param name="info">Database metadata information</param>
/// <param name="r">DataRow with data</param>
/// <param name="fieldInfo">Fields which need to update</param>
/// <param name="tableName">DB table name</param>
/// <param name="primaryKeyName">Primary key's name</param>
/// <param name="cleanup">
/// Cleanup will remove from query fields:
/// NowOnUpdate - while will be done insert
/// NowOnInsert - while will be done update
/// </param>
/// <returns>sql query</returns>
Crafts update query with cleanup, without checking DataRow::RowState
Crafts update query with cleanup without checking DataRow :: RowState
public static string CraftUpdateQuery (
			DatabasesInfo info, 
			DataRow r,
			DbFieldInfo[] fieldInfo,
			string tableName, 
			string primaryKeyName,
			bool cleanup)
		{
			DbFieldInfo[] fields;
			if (cleanup)
			{
				fields = Cleanup (fieldInfo, ForWhat.ForUpdate);
			}
			else
			{
				fields = fieldInfo;
			}
			string sql = info.TokenUpdate + " " + info.GetTableName(tableName) + " SET ";
			string[] values = GetValues (info, r, fields, ForWhat.ForUpdate);
			List<string> setters = new List<string> ();
			for (int i = 0; i < fields.Length; i++)
			{
				setters.Add(
					info.GetFieldName (string.Empty, fields[i].Name) + " = " + values[i]);
			}
			sql += string.Join (", ", setters.ToArray ());
			sql += " " + info.TokenWhere + " " + info.GetFieldName (null, primaryKeyName) + " = '" + r[primaryKeyName].ToString () + "'";
			return sql;
		}
public static string CraftUpdateQuery ( DatabasesInfo info , DataRow r , DbFieldInfo [ ] fieldInfo , string tableName , string primaryKeyName , bool cleanup ) { DbFieldInfo [ ] fields ; if ( cleanup ) { fields = Cleanup ( fieldInfo , ForWhat . ForUpdate ) ; } else { fields = fieldInfo ; } string sql = info . TokenUpdate + " " + info . GetTableName ( tableName ) + " " ; string [ ] values = GetValues ( info , r , fields , ForWhat . ForUpdate ) ; List < string > setters = new List < string > ( ) ; for ( int i = 0 ; i < fields . Length ; i ++ ) { setters . Add ( info . GetFieldName ( string . Empty , fields [ i ] . Name ) + " " + values [ i ] ) ; } sql += string . Join ( " " , setters . ToArray ( ) ) ; sql += " " + info . TokenWhere + " " + info . GetFieldName ( null , primaryKeyName ) + " " + r [ primaryKeyName ] . ToString ( ) + " " ; return sql ; }
Crafts update query with cleanup, without checking DataRow::RowState
Crafts update query with cleanup without checking DataRow :: RowState
// update header // i=value // whereCause
None
info
DatabasesInfo
Database metadata information
Database metadata information
r
DataRow
DataRow with data
DataRow with data
fieldInfo
DbFieldInfo[]
Fields which need to update
Fields which need to update
tableName
string
DB table name
DB table name
primaryKeyName
string
Primary key's name
Primary key ' s name
cleanup
bool
Cleanup will remove from query fields:
NowOnUpdate - while will be done insert
NowOnInsert - while will be done update
Cleanup will remove from query fields : NowOnUpdate - while will be done insert NowOnInsert - while will be done update