trunk/src/LythumOSL.Core/Data/Database.cs
/// <summary>
/// Crafts insert 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="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 insert query with cleanup, without checking DataRow::RowState
Crafts insert query with cleanup without checking DataRow :: RowState
public static string CraftInsertQuery (
			DatabasesInfo info, 
			DataRow r,
			DbFieldInfo[] fieldInfo, 
			string tableName,
			bool cleanup)
		{
			DbFieldInfo[] fields;
			if (cleanup)
			{
				fields = Cleanup (fieldInfo, ForWhat.ForInsert);
			}
			else
			{
				fields = fieldInfo;
			}
			List<string> names = new List<string> ();
			foreach (DbFieldInfo i in fields)
			{
				names.Add (i.Name);
			}
			string sql = info.TokenInsert + " " + info.GetTableName (tableName) + " (";
			sql += info.FieldNamePrefix + string.Join (
				info.FieldNamePostfix + ", " + info.FieldNamePrefix,
				names.ToArray()) + info.FieldNamePostfix;
			sql += ") VALUES (";
			string[] values = GetValues(info, r, fields, ForWhat.ForInsert);
			sql += string.Join (", ", values) + ")";
			return sql;
		}
public static string CraftInsertQuery ( DatabasesInfo info , DataRow r , DbFieldInfo [ ] fieldInfo , string tableName , bool cleanup ) { DbFieldInfo [ ] fields ; if ( cleanup ) { fields = Cleanup ( fieldInfo , ForWhat . ForInsert ) ; } else { fields = fieldInfo ; } List < string > names = new List < string > ( ) ; foreach ( DbFieldInfo i in fields ) { names . Add ( i . Name ) ; } string sql = info . TokenInsert + " " + info . GetTableName ( tableName ) + " " ; sql += info . FieldNamePrefix + string . Join ( info . FieldNamePostfix + " " + info . FieldNamePrefix , names . ToArray ( ) ) + info . FieldNamePostfix ; sql += " " ; string [ ] values = GetValues ( info , r , fields , ForWhat . ForInsert ) ; sql += string . Join ( " " , values ) + " " ; return sql ; }
Crafts insert query with cleanup, without checking DataRow::RowState
Crafts insert query with cleanup without checking DataRow :: RowState
// collecting field names for join // insert header // field names // field values
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
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