public static string ConstructInsertQuery(this DirectModel model, List <string> avaliableVariables = null) // we use this avaliableVariables in Later load insert from TransactionalManager { model.OnBeforeInsert(); string command = string.Format("INSERT INTO {0}.{1}{2} ({3}) VALUES ({4});", model.GetDatabase().DatabaseName, model.GetDatabase().DatabaseSchemeString, model.GetTableName(), model.Snapshot.GetPropertyNamesForInsert(), model.Snapshot.GetPropertyValuesForInsert(false, avaliableVariables)); return(command); }
internal static string ConstructUpdateQuery(this DirectModel model) { if (!model.LongID.HasValue) { throw new Exception("ID is not set, maybe this table was not loaded"); } model.OnBeforeUpdate(); // UPDATE MobilePaywall.core.A SET A=1 WHERE AID=1 string command = string.Format("UPDATE {0}.{1}{2} SET {3} WHERE {4}={5};", model.GetDatabase().DatabaseName, model.GetDatabase().DatabaseSchemeString, model.GetTableName(), model.Snapshot.GetUpdateData(), model.GetIdNameValue(), model.LongID.Value); return(command); }
public static void InsertLater(this DirectModel model) { model.GetDatabase().TransactionalManager.Add(model.ConstructInsertQuery()); }