public static bool TableInsert(System.Collections.Generic.Dictionary <string, object> coulmns, string tableName, OracleDapperOld db, DbTransaction t) { bool result = false; if (coulmns != null && coulmns.Count > 0) { DbCommand dbCommand = db.CreateCommand(); dbCommand.CommandType = CommandType.Text; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.AppendFormat("Insert INTO {0} (", tableName); int num = 0; foreach (string current in coulmns.Keys) { if (num > 0) { stringBuilder.Append(","); } stringBuilder.Append(current); num++; } stringBuilder.Append(" ) VALUES ( "); num = 0; foreach (System.Collections.Generic.KeyValuePair <string, object> current2 in coulmns) { if (num > 0) { stringBuilder.Append(","); } string text = db.ParameterToken + "p_" + current2.Key; stringBuilder.Append(text); db.AddInParameter(dbCommand, text, DatabaseHelper.ObjectToDbType(current2.Value), current2.Value); num++; } stringBuilder.Append(" )"); dbCommand.CommandText = stringBuilder.ToString(); result = ((t == null) ? (db.ExecuteNonQuery(dbCommand) > 0) : (db.ExecuteNonQuery(dbCommand, t) > 0)); } return(result); }
public static bool TableUpdate(System.Collections.Generic.Dictionary <string, object> coulmns, System.Collections.Generic.Dictionary <string, object> primaryKeys, string tableName, OracleDapperOld db, DbTransaction t) { bool result = false; if (coulmns != null && coulmns.Count > 0 && primaryKeys != null && primaryKeys.Count > 0) { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); DbCommand dbCommand = db.CreateCommand(); dbCommand.CommandType = CommandType.Text; stringBuilder.AppendFormat("Update {0} SET ", tableName); int num = 0; foreach (System.Collections.Generic.KeyValuePair <string, object> current in coulmns) { if (num > 0) { stringBuilder.Append(","); } string text = db.ParameterToken + "pu_" + current.Key; stringBuilder.AppendFormat(" {0} = {1}", current.Key, text); db.AddInParameter(dbCommand, text, DatabaseHelper.ObjectToDbType(current.Value), current.Value); num++; } num = 0; foreach (System.Collections.Generic.KeyValuePair <string, object> current in primaryKeys) { stringBuilder.Append((num == 0) ? " WHERE " : " AND "); string text = db.ParameterToken + "pw_" + current.Key; stringBuilder.AppendFormat(" {0} = {1} ", current.Key, text); db.AddInParameter(dbCommand, text, DatabaseHelper.ObjectToDbType(current.Value), current.Value); num++; } dbCommand.CommandText = stringBuilder.ToString(); result = ((t == null) ? (db.ExecuteNonQuery(dbCommand) > 0) : (db.ExecuteNonQuery(dbCommand, t) > 0)); } return(result); }