public static string GetPreParameter(List <ColumnInfo> keys, bool IdentityisPrior, string DbType) { StringPlus stringPlus1 = new StringPlus(); StringPlus stringPlus2 = new StringPlus(); stringPlus1.AppendSpaceLine(3, CodeCommon.DbParaHead(DbType) + "Parameter[] parameters = {"); ColumnInfo identityKey = CodeCommon.GetIdentityKey(keys); bool flag = CodeCommon.HasNoIdentityKey(keys); if (IdentityisPrior && identityKey != null || !flag && identityKey != null) { stringPlus1.AppendSpaceLine(5, "new " + CodeCommon.DbParaHead(DbType) + "Parameter(\"" + CodeCommon.preParameter(DbType) + identityKey.ColumnName + "\", " + CodeCommon.DbParaDbType(DbType) + "." + CodeCommon.DbTypeLength(DbType, identityKey.TypeName, "") + ")"); stringPlus2.AppendSpaceLine(3, "parameters[0].Value = " + identityKey.ColumnName + ";"); } else { int num = 0; foreach (ColumnInfo columnInfo in keys) { if (columnInfo.IsPrimaryKey || !columnInfo.IsIdentity) { stringPlus1.AppendSpaceLine(5, "new " + CodeCommon.DbParaHead(DbType) + "Parameter(\"" + CodeCommon.preParameter(DbType) + columnInfo.ColumnName + "\", " + CodeCommon.DbParaDbType(DbType) + "." + CodeCommon.DbTypeLength(DbType, columnInfo.TypeName, columnInfo.Length) + "),"); stringPlus2.AppendSpaceLine(3, "parameters[" + num.ToString() + "].Value = " + columnInfo.ColumnName + ";"); ++num; } } stringPlus1.DelLastComma(); } stringPlus1.AppendSpaceLine(3, "};"); stringPlus1.Append(stringPlus2.Value); return(stringPlus1.Value); }
public static string DbTypeLength(string dbtype, string datatype, string Length) { string str = ""; switch (dbtype) { case "SQL2000": case "SQL2005": case "SQL2008": case "SQL2012": str = CodeCommon.DbTypeLengthSQL(dbtype, datatype, Length); break; case "Oracle": str = CodeCommon.DbTypeLengthOra(datatype, Length); break; case "MySQL": str = CodeCommon.DbTypeLengthMySQL(datatype, Length); break; case "OleDb": str = CodeCommon.DbTypeLengthOleDb(datatype, Length); break; case "SQLite": str = CodeCommon.DbTypeLengthSQLite(datatype, Length); break; } return(str); }
public static string CSToProcType(string DbType, string cstype) { string str = cstype; switch (DbType) { case "SQL2000": case "SQL2005": case "SQL2008": case "SQL2012": str = CodeCommon.CSToProcTypeSQL(cstype); break; case "Oracle": str = CodeCommon.CSToProcTypeOra(cstype); break; case "MySQL": str = CodeCommon.CSToProcTypeMySQL(cstype); break; case "OleDb": str = CodeCommon.CSToProcTypeOleDb(cstype); break; case "SQLite": str = CodeCommon.CSToProcTypeSQLite(cstype); break; } return(str); }
private static string DbTypeLengthMySQL(string datatype, string Length) { string str = ""; switch (datatype.Trim().ToLower()) { case "number": str = !(Length == "") ? Length : "4"; goto case "date"; case "varchar2": str = !(Length == "") ? Length : "50"; goto case "date"; case "char": str = !(Length == "") ? Length : "50"; goto case "date"; case "date": case "nchar": case "nvarchar2": case "long": case "long raw": case "bfile": case "blob": return(!(str != "") ? CodeCommon.CSToProcType("MySQL", datatype) : CodeCommon.CSToProcType("MySQL", datatype) + "," + str); default: str = Length; goto case "date"; } }
private static string DbTypeLengthSQLite(string datatype, string Length) { string str = ""; switch (datatype.Trim()) { case "int": case "integer": str = !(Length == "") ? Length : "4"; goto case "image"; case "varchar": str = !(Length == "") ? Length : "50"; goto case "image"; case "char": str = !(Length == "") ? Length : "50"; goto case "image"; case "bit": str = "1"; goto case "image"; case "float": case "numeric": case "decimal": case "money": case "smallmoney": case "binary": case "smallint": case "bigint": case "blob": str = Length; goto case "image"; case "image": case "datetime": case "smalldatetime": case "nchar": case "nvarchar": case "ntext": case "text": case "time": case "date": case "boolean": return(!(str != "") ? CodeCommon.CSToProcType("SQLite", datatype) : CodeCommon.CSToProcType("SQLite", datatype) + "," + str); default: str = Length; goto case "image"; } }
private static string DbTypeLengthSQL(string dbtype, string datatype, string Length) { string str1 = CodeCommon.GetDataTypeLenVal(datatype, Length); string str2; if (str1 != "") { if (str1 == "MAX") { str1 = "-1"; } str2 = CodeCommon.CSToProcType(dbtype, datatype) + "," + str1; } else { str2 = CodeCommon.CSToProcType(dbtype, datatype); } return(str2); }
public static string GetFieldstrlistAdd(List <ColumnInfo> keys, bool IdentityisPrior) { StringPlus stringPlus = new StringPlus(); ColumnInfo identityKey = CodeCommon.GetIdentityKey(keys); if (IdentityisPrior && identityKey != null) { stringPlus.Append(identityKey.ColumnName); } else { foreach (ColumnInfo columnInfo in keys) { if (columnInfo.IsPrimaryKey || !columnInfo.IsIdentity) { stringPlus.Append(columnInfo.ColumnName + "+"); } } stringPlus.DelLastChar("+"); } return(stringPlus.Value); }
public static string GetInParameter(List <ColumnInfo> keys, bool IdentityisPrior) { StringPlus stringPlus = new StringPlus(); ColumnInfo identityKey = CodeCommon.GetIdentityKey(keys); if (IdentityisPrior && identityKey != null) { stringPlus.Append(CodeCommon.DbTypeToCS(identityKey.TypeName) + " " + identityKey.ColumnName); } else { foreach (ColumnInfo columnInfo in keys) { if (columnInfo.IsPrimaryKey || !columnInfo.IsIdentity) { stringPlus.Append(CodeCommon.DbTypeToCS(columnInfo.TypeName) + " " + columnInfo.ColumnName + ","); } } stringPlus.DelLastComma(); } return(stringPlus.Value); }
public static string GetWhereParameterExpression(List <ColumnInfo> keys, bool IdentityisPrior, string DbType) { StringPlus stringPlus = new StringPlus(); ColumnInfo identityKey = CodeCommon.GetIdentityKey(keys); bool flag = CodeCommon.HasNoIdentityKey(keys); if (IdentityisPrior && identityKey != null || !flag && identityKey != null) { stringPlus.Append(identityKey.ColumnName + "=" + CodeCommon.preParameter(DbType) + identityKey.ColumnName); } else { foreach (ColumnInfo columnInfo in keys) { if (columnInfo.IsPrimaryKey || !columnInfo.IsIdentity) { stringPlus.Append(columnInfo.ColumnName + "=" + CodeCommon.preParameter(DbType) + columnInfo.ColumnName + " and "); } } stringPlus.DelLastChar("and"); } return(stringPlus.Value); }
public static string GetModelWhereExpression(List <ColumnInfo> keys, bool IdentityisPrior) { StringPlus stringPlus = new StringPlus(); ColumnInfo identityKey = CodeCommon.GetIdentityKey(keys); if (IdentityisPrior && identityKey != null) { if (CodeCommon.IsAddMark(identityKey.TypeName)) { stringPlus.Append(identityKey.ColumnName + "='\"+ model." + identityKey.ColumnName + "+\"'"); } else { stringPlus.Append(identityKey.ColumnName + "=\"+ model." + identityKey.ColumnName + "+\""); } } else { foreach (ColumnInfo columnInfo in keys) { if (columnInfo.IsPrimaryKey || !columnInfo.IsIdentity) { if (CodeCommon.IsAddMark(columnInfo.TypeName)) { stringPlus.Append(columnInfo.ColumnName + "='\"+ model." + columnInfo.ColumnName + "+\"' and "); } else { stringPlus.Append(columnInfo.ColumnName + "=\"+ model." + columnInfo.ColumnName + "+\" and "); } } } stringPlus.DelLastChar("and"); } return(stringPlus.Value); }