protected static string GetToHashtableFieldConcat(ColumnInfo columnInfo) { switch (columnInfo.Type) { case SqlDbType.Bit: case SqlDbType.TinyInt: case SqlDbType.SmallInt: case SqlDbType.Int: case SqlDbType.BigInt: case SqlDbType.Decimal: case SqlDbType.SmallMoney: case SqlDbType.Money: case SqlDbType.Float: case SqlDbType.Real: return(string.Format("{0}", CodeBuild.UFString(columnInfo.Name))); case SqlDbType.Date: case SqlDbType.DateTime: case SqlDbType.DateTime2: case SqlDbType.SmallDateTime: return(string.Format("{0}.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds", CodeBuild.UFString(columnInfo.Name))); case SqlDbType.DateTimeOffset: return(string.Format("{0}.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds", CodeBuild.UFString(columnInfo.Name))); case SqlDbType.Time: return(string.Format("{0}.Value.Ticks", CodeBuild.UFString(columnInfo.Name))); case SqlDbType.Binary: case SqlDbType.VarBinary: case SqlDbType.Image: return(string.Format("Convert.ToBase64String({0})", CodeBuild.UFString(columnInfo.Name))); case SqlDbType.UniqueIdentifier: return(string.Format("{0}", CodeBuild.UFString(columnInfo.Name))); case SqlDbType.Char: case SqlDbType.VarChar: case SqlDbType.Text: case SqlDbType.NChar: case SqlDbType.NVarChar: case SqlDbType.NText: return(string.Format("{0}", CodeBuild.UFString(columnInfo.Name))); case SqlDbType.Timestamp: default: return(string.Format("{0}", CodeBuild.UFString(columnInfo.Name))); } }
protected static string AppendParameter(ColumnInfo col, string value, string place) { if (col == null) { return(""); } string type = ""; string type2 = ""; if (col.Attndims > 0) { type += " | NpgsqlDbType.Array"; } switch (col.Type) { case NpgsqlDbType.Smallint: case NpgsqlDbType.Integer: case NpgsqlDbType.Bigint: case NpgsqlDbType.Numeric: case NpgsqlDbType.Real: case NpgsqlDbType.Double: case NpgsqlDbType.Money: case NpgsqlDbType.Char: case NpgsqlDbType.Varchar: case NpgsqlDbType.Text: case NpgsqlDbType.Timestamp: case NpgsqlDbType.TimestampTZ: case NpgsqlDbType.Date: case NpgsqlDbType.Time: case NpgsqlDbType.TimeTZ: case NpgsqlDbType.Interval: case NpgsqlDbType.Boolean: case NpgsqlDbType.Bytea: case NpgsqlDbType.Bit: case NpgsqlDbType.Varbit: case NpgsqlDbType.Point: case NpgsqlDbType.Line: case NpgsqlDbType.LSeg: case NpgsqlDbType.Box: case NpgsqlDbType.Path: case NpgsqlDbType.Polygon: case NpgsqlDbType.Circle: case NpgsqlDbType.Cidr: case NpgsqlDbType.Inet: case NpgsqlDbType.MacAddr: case NpgsqlDbType.Json: case NpgsqlDbType.Jsonb: case NpgsqlDbType.Uuid: type += " | NpgsqlDbType." + col.Type.ToString(); break; case NpgsqlDbType.IntegerRange: type += " | NpgsqlDbType.Range | NpgsqlDbType.Integer"; break; case NpgsqlDbType.BigintRange: type += " | NpgsqlDbType.Range | NpgsqlDbType.Bigint"; break; case NpgsqlDbType.NumericRange: type += " | NpgsqlDbType.Range | NpgsqlDbType.Numeric"; break; case NpgsqlDbType.TimestampRange: type += " | NpgsqlDbType.Range | NpgsqlDbType.Timestamp"; break; case NpgsqlDbType.TimestampTZRange: type += " | NpgsqlDbType.Range | NpgsqlDbType.TimestampTZ"; break; case NpgsqlDbType.DateRange: type += " | NpgsqlDbType.Range | NpgsqlDbType.Date"; break; case NpgsqlDbType.Enum: case NpgsqlDbType.Composite: type += " | NpgsqlDbType." + col.Type.ToString(); type2 = "SpecificType = typeof(" + Regex.Replace(col.CsType.Replace("?", ""), @"\[\,*\]", "") + "), "; break; default: type += " | NpgsqlDbType." + col.Type.ToString(); break; } string returnValue = place + string.Format("new NpgsqlParameter(\"{0}\", {1}, {2}) {{ {4}Value = {3} }}, \r\n", col.Name, type.Substring(3), col.Length, value + CodeBuild.UFString(col.Name), type2); return(returnValue); }
protected static string GetToStringFieldConcat(ColumnInfo columnInfo) { switch (columnInfo.Type) { case SqlDbType.Bit: return(string.Format("{0} == null ? \"null\" : ({0} == true ? \"true\" : \"false\")", CodeBuild.UFString(columnInfo.Name))); case SqlDbType.TinyInt: case SqlDbType.SmallInt: case SqlDbType.Int: case SqlDbType.BigInt: case SqlDbType.Decimal: case SqlDbType.SmallMoney: case SqlDbType.Money: case SqlDbType.Float: //string.Format("", {0} : {{0}}"", {0} == null ? ""null"" : {0}.ToString()) case SqlDbType.Real: return(string.Format("{0} == null ? \"null\" : {0}.ToString()", CodeBuild.UFString(columnInfo.Name))); // "'\" + _" + CodeBuild.UFString(columnInfo.Name) + " +\r\n \"'"; case SqlDbType.Date: case SqlDbType.DateTime: case SqlDbType.DateTime2: //string.Format("\", {0} == null ? \"null\" : string.Concat(\"Date(\", {0}.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds, \")\"), \r\n \"", CodeBuild.UFString(columnInfo.Name)); case SqlDbType.SmallDateTime: return(string.Format("{0} == null ? \"null\" : string.Concat(\"\", {0}.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds, \"\")", CodeBuild.UFString(columnInfo.Name))); case SqlDbType.DateTimeOffset: return(string.Format("{0} == null ? \"null\" : string.Concat(\"\", {0}.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds, \"\")", CodeBuild.UFString(columnInfo.Name))); case SqlDbType.Time: return(string.Format("{0} == null ? \"null\" : string.Concat(\"\", {0}.Value.Ticks, \"\")", CodeBuild.UFString(columnInfo.Name))); case SqlDbType.Binary: case SqlDbType.VarBinary: // return "\" + (_" + CodeBuild.UFString(columnInfo.Name) + " == null ? null : Encoding.UTF8.GetString(_" + CodeBuild.UFString(columnInfo.Name) + ")) +\r\n \""; case SqlDbType.Image: return(string.Format("{0} == null ? \"null\" : Convert.ToBase64String({0})", CodeBuild.UFString(columnInfo.Name))); //return "'\" + _" + CodeBuild.UFString(columnInfo.Name) + " +\r\n \"'"; case SqlDbType.UniqueIdentifier: return(string.Format("{0} == null ? \"null\" : {0}.ToString()", CodeBuild.UFString(columnInfo.Name))); case SqlDbType.Char: case SqlDbType.VarChar: case SqlDbType.Text: case SqlDbType.NChar: case SqlDbType.NVarChar: // return "'\" + (_" + CodeBuild.UFString(columnInfo.Name) + " == null ? string.Empty : _" + CodeBuild.UFString(columnInfo.Name) + ".Replace(\"\\\\\", \"\\\\\\\\\").Replace(\"\\r\\n\", \"\\\\r\\\\n\").Replace(\"'\", \"\\\\'\")) + \r\n \"'"; case SqlDbType.NText: return(string.Format("{0} == null ? \"null\" : string.Format(\"'{{0}}'\", {0}.Replace(\"\\\\\", \"\\\\\\\\\").Replace(\"\\r\\n\", \"\\\\r\\\\n\").Replace(\"'\", \"\\\\'\"))", CodeBuild.UFString(columnInfo.Name))); case SqlDbType.Timestamp: return(string.Format("{0} == null ? \"null\" : Convert.ToBase64String({0})", CodeBuild.UFString(columnInfo.Name))); default: return(string.Format("{0} == null ? \"null\" : {0}.ToString()", CodeBuild.UFString(columnInfo.Name))); } }
protected static string GetToStringStringify(ColumnInfo columnInfo) { switch (columnInfo.Type) { case NpgsqlDbType.Smallint: case NpgsqlDbType.Integer: case NpgsqlDbType.Bigint: case NpgsqlDbType.Numeric: case NpgsqlDbType.Real: case NpgsqlDbType.Double: case NpgsqlDbType.Money: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".ToString()"); case NpgsqlDbType.Char: case NpgsqlDbType.Varchar: case NpgsqlDbType.Text: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".Replace(\"|\", StringifySplit)"); case NpgsqlDbType.Timestamp: case NpgsqlDbType.TimestampTZ: case NpgsqlDbType.Date: case NpgsqlDbType.Time: case NpgsqlDbType.TimeTZ: case NpgsqlDbType.Interval: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".Value.Ticks.ToString()"); case NpgsqlDbType.Boolean: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : (_" + CodeBuild.UFString(columnInfo.Name) + " == true ? \"1\" : \"0\")"); case NpgsqlDbType.Bytea: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : Convert.ToBase64String(_" + CodeBuild.UFString(columnInfo.Name) + ")"); case NpgsqlDbType.Bit: case NpgsqlDbType.Varbit: return(string.Format("{0} == null ? \"null\" : {0}.To1010()", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.Point: case NpgsqlDbType.Line: case NpgsqlDbType.LSeg: case NpgsqlDbType.Box: case NpgsqlDbType.Path: case NpgsqlDbType.Polygon: case NpgsqlDbType.Circle: case NpgsqlDbType.Cidr: case NpgsqlDbType.Inet: case NpgsqlDbType.MacAddr: return(string.Format("{0} == null ? \"null\" : {0}.ToString()", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.Json: case NpgsqlDbType.Jsonb: case NpgsqlDbType.Uuid: return(string.Format("{0} == null ? \"null\" : {0}.ToString()", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.IntegerRange: case NpgsqlDbType.BigintRange: case NpgsqlDbType.NumericRange: case NpgsqlDbType.TimestampRange: case NpgsqlDbType.TimestampTZRange: case NpgsqlDbType.DateRange: return(string.Format("{0} == null ? \"null\" : {0}.ToString()", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.Hstore: case NpgsqlDbType.Enum: case NpgsqlDbType.Composite: default: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".ToString().Replace(\"|\", StringifySplit)"); } }
protected static string GetToStringFieldConcat(ColumnInfo columnInfo, string csType) { switch (columnInfo.Type) { case NpgsqlDbType.Smallint: case NpgsqlDbType.Integer: case NpgsqlDbType.Bigint: case NpgsqlDbType.Numeric: case NpgsqlDbType.Real: case NpgsqlDbType.Double: case NpgsqlDbType.Money: return(string.Format("{0} == null ? \"null\" : {0}.ToString()", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.Char: case NpgsqlDbType.Varchar: case NpgsqlDbType.Text: return(string.Format("{0} == null ? \"null\" : string.Format(\"'{{0}}'\", {0}.Replace(\"\\\\\", \"\\\\\\\\\").Replace(\"\\r\\n\", \"\\\\r\\\\n\").Replace(\"'\", \"\\\\'\"))", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.Timestamp: case NpgsqlDbType.TimestampTZ: case NpgsqlDbType.Date: return(string.Format("{0} == null ? \"null\" : {0}.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString()", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.Time: case NpgsqlDbType.TimeTZ: case NpgsqlDbType.Interval: return(string.Format("{0} == null ? \"null\" : {0}.Value.TotalMilliseconds.ToString()", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.Boolean: return(string.Format("{0} == null ? \"null\" : ({0} == true ? \"true\" : \"false\")", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.Bytea: return(string.Format("{0} == null ? \"null\" : Convert.ToBase64String({0})", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.Bit: case NpgsqlDbType.Varbit: return(string.Format("{0} == null ? \"null\" : string.Format(\"'{{0}}'\", {0}.To1010())", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.Point: case NpgsqlDbType.Line: case NpgsqlDbType.LSeg: case NpgsqlDbType.Box: case NpgsqlDbType.Path: case NpgsqlDbType.Polygon: case NpgsqlDbType.Circle: case NpgsqlDbType.Cidr: case NpgsqlDbType.Inet: case NpgsqlDbType.MacAddr: return(string.Format("{0} == null ? \"null\" : {0}.ToString()", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.Json: case NpgsqlDbType.Jsonb: case NpgsqlDbType.Uuid: return(string.Format("{0} == null ? \"null\" : {0}.ToString()", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.IntegerRange: case NpgsqlDbType.BigintRange: case NpgsqlDbType.NumericRange: case NpgsqlDbType.TimestampRange: case NpgsqlDbType.TimestampTZRange: case NpgsqlDbType.DateRange: return(string.Format("{0} == null ? \"null\" : {0}.ToString()", CodeBuild.UFString(columnInfo.Name))); case NpgsqlDbType.Hstore: case NpgsqlDbType.Enum: case NpgsqlDbType.Composite: default: return(string.Format("{0} == null ? \"null\" : {0}.ToString()", CodeBuild.UFString(columnInfo.Name))); } }
protected static string GetToStringStringify(ColumnInfo columnInfo) { switch (columnInfo.Type) { case SqlDbType.Bit: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : (_" + CodeBuild.UFString(columnInfo.Name) + " == true ? \"1\" : \"0\")"); case SqlDbType.TinyInt: case SqlDbType.SmallInt: case SqlDbType.Int: case SqlDbType.BigInt: case SqlDbType.Decimal: case SqlDbType.SmallMoney: case SqlDbType.Money: case SqlDbType.Float: case SqlDbType.Real: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".ToString()"); case SqlDbType.Date: case SqlDbType.DateTime: case SqlDbType.SmallDateTime: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".ToString()"); case SqlDbType.Binary: case SqlDbType.VarBinary: case SqlDbType.Image: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : Convert.ToBase64String(_" + CodeBuild.UFString(columnInfo.Name) + ")"); case SqlDbType.UniqueIdentifier: return("_" + CodeBuild.UFString(columnInfo.Name)); case SqlDbType.Char: case SqlDbType.VarChar: case SqlDbType.Text: case SqlDbType.NChar: case SqlDbType.NVarChar: case SqlDbType.NText: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".Replace(\"|\", StringifySplit)"); case SqlDbType.Timestamp: default: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".ToString().Replace(\"|\", StringifySplit)"); } }
protected static string GetToStringStringify(ColumnInfo columnInfo) { switch (columnInfo.Type) { case MySqlDbType.Bit: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : (_" + CodeBuild.UFString(columnInfo.Name) + " == true ? \"1\" : \"0\")"); case MySqlDbType.Byte: case MySqlDbType.Int16: case MySqlDbType.Int24: case MySqlDbType.Int32: case MySqlDbType.Int64: case MySqlDbType.UByte: case MySqlDbType.UInt16: case MySqlDbType.UInt24: case MySqlDbType.UInt32: case MySqlDbType.UInt64: case MySqlDbType.Double: case MySqlDbType.Float: case MySqlDbType.Decimal: case MySqlDbType.Year: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".ToString()"); case MySqlDbType.Time: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".Value.TotalSeconds.ToString()"); case MySqlDbType.Date: case MySqlDbType.Timestamp: case MySqlDbType.Datetime: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".Value.Ticks.ToString()"); case MySqlDbType.TinyBlob: case MySqlDbType.Blob: case MySqlDbType.MediumBlob: case MySqlDbType.LongBlob: case MySqlDbType.Binary: case MySqlDbType.VarBinary: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : Convert.ToBase64String(_" + CodeBuild.UFString(columnInfo.Name) + ")"); case MySqlDbType.TinyText: case MySqlDbType.Text: case MySqlDbType.MediumText: case MySqlDbType.LongText: case MySqlDbType.String: case MySqlDbType.VarString: case MySqlDbType.VarChar: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".Replace(\"|\", StringifySplit)"); case MySqlDbType.Set: case MySqlDbType.Enum: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".ToInt64().ToString()"); case MySqlDbType.Geometry: string csTypeGeom = GetCSTypeGeometry(columnInfo.SqlType); string asText = csTypeGeom == "object" ? ".ToString()" : ".AsText()"; return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + asText + ".Replace(\"|\", StringifySplit)"); default: return("_" + CodeBuild.UFString(columnInfo.Name) + " == null ? \"null\" : _" + CodeBuild.UFString(columnInfo.Name) + ".ToString().Replace(\"|\", StringifySplit)"); } }
protected static string GetToStringFieldConcat(ColumnInfo columnInfo, string csType) { switch (columnInfo.Type) { case MySqlDbType.Bit: return(string.Format("{0} == null ? \"null\" : ({0} == true ? \"true\" : \"false\")", CodeBuild.UFString(columnInfo.Name))); case MySqlDbType.Byte: case MySqlDbType.Int16: case MySqlDbType.Int24: case MySqlDbType.Int32: case MySqlDbType.Int64: case MySqlDbType.UByte: case MySqlDbType.UInt16: case MySqlDbType.UInt24: case MySqlDbType.UInt32: case MySqlDbType.UInt64: case MySqlDbType.Double: case MySqlDbType.Float: case MySqlDbType.Decimal: case MySqlDbType.Year: return(string.Format("{0} == null ? \"null\" : {0}.ToString()", CodeBuild.UFString(columnInfo.Name))); case MySqlDbType.Time: return(string.Format("{0} == null ? \"null\" : {0}.Value.TotalSeconds.ToString()", CodeBuild.UFString(columnInfo.Name))); case MySqlDbType.Date: case MySqlDbType.Timestamp: case MySqlDbType.Datetime: return(string.Format("{0} == null ? \"null\" : {0}.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString()", CodeBuild.UFString(columnInfo.Name))); case MySqlDbType.TinyBlob: case MySqlDbType.Blob: case MySqlDbType.MediumBlob: case MySqlDbType.LongBlob: case MySqlDbType.Binary: case MySqlDbType.VarBinary: return(string.Format("{0} == null ? \"null\" : Convert.ToBase64String({0})", CodeBuild.UFString(columnInfo.Name))); case MySqlDbType.TinyText: case MySqlDbType.Text: case MySqlDbType.MediumText: case MySqlDbType.LongText: case MySqlDbType.String: case MySqlDbType.VarString: case MySqlDbType.VarChar: return(string.Format("{0} == null ? \"null\" : string.Format(\"'{{0}}'\", {0}.Replace(\"\\\\\", \"\\\\\\\\\").Replace(\"\\r\\n\", \"\\\\r\\\\n\").Replace(\"'\", \"\\\\'\"))", CodeBuild.UFString(columnInfo.Name))); case MySqlDbType.Set: return(string.Format("{0} == null ? \"null\" : string.Format(\"[ '{{0}}' ]\", string.Join(\"', '\", {0}.ToInt64().ToSet<{1}>().Select<{1}, string>(a => a.ToDescriptionOrString().Replace(\"\\\\\", \"\\\\\\\\\").Replace(\"\\r\\n\", \"\\\\r\\\\n\").Replace(\"'\", \"\\\\'\"))))", CodeBuild.UFString(columnInfo.Name), csType)); case MySqlDbType.Enum: return(string.Format("{0} == null ? \"null\" : string.Format(\"'{{0}}'\", {0}.ToDescriptionOrString().Replace(\"\\\\\", \"\\\\\\\\\").Replace(\"\\r\\n\", \"\\\\r\\\\n\").Replace(\"'\", \"\\\\'\"))", CodeBuild.UFString(columnInfo.Name))); case MySqlDbType.Geometry: string csTypeGeom = GetCSTypeGeometry(columnInfo.SqlType); string asText = csTypeGeom == "object" ? ".ToString()" : ".AsText()"; return(string.Format("{0} == null ? \"null\" : string.Format(\"'{{0}}'\", {0}" + asText + ".Replace(\"\\\\\", \"\\\\\\\\\").Replace(\"\\r\\n\", \"\\\\r\\\\n\").Replace(\"'\", \"\\\\'\"))", CodeBuild.UFString(columnInfo.Name))); default: return(string.Format("{0} == null ? \"null\" : {0}.ToString()", CodeBuild.UFString(columnInfo.Name))); } }