public static string update(string[] cols, Type table_, ConditionString conditionString = null) { var table = (Model)Activator.CreateInstance(table_); string values = string.Join(",", cols.Select(str => str).ToArray()); if (conditionString != null) { return(string.Format("update {0} set {1} where {2}", table.tableName, values, conditionString.conditions)); } else { return(string.Format("update {0} set {1}", table.tableName, values)); } }
public static string delete(Type table_, ConditionString conditionString = null) { // delete from tableName where aldsjf=123 var table = (Model)Activator.CreateInstance(table_); if (conditionString != null) { return(string.Format("delete from {0} where {1}", table.tableName, conditionString.conditions)); } else { return(string.Format("delete from {0}", table.tableName)); } }
public static string select(ModelColumn[] cols, Type table_, ConditionString conditionString = null) { var table = (Model)Activator.CreateInstance(table_); string colNames = string.Join(",", cols.Select(col => col.colName).ToArray()); if (conditionString != null) { return(string.Format("select {0} from {1} where {2}", colNames, table.tableName, conditionString.conditions)); } else { return(string.Format("select {0} from {1}", colNames, table.tableName)); } }