Created
February 27, 2018 05:45
-
-
Save talkingdotnet/891cce45735cbf78b39dbcd59cf3ee31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private object ConvertDataTypes(object col) | |
{ | |
if (col == null) | |
return "NULL"; | |
switch (col.GetType().FullName) | |
{ | |
case "System.Int16": | |
case "System.Int32": | |
case "System.Int64": | |
case "System.UInt16": | |
case "System.UInt32": | |
case "System.UInt64": | |
case "System.Byte": | |
case "System.SByte": | |
case "System.Single": | |
case "System.Double": | |
case "System.Decimal": | |
case "System.Boolean": | |
return col; | |
case "System.DBNull": | |
return "NULL"; | |
case "System.Guid": | |
case "System.String": | |
return $"\"{col.ToString().Replace("\"", "\\\"").Replace("'", "\\'")}\""; | |
case "System.DateTime": | |
return $"\"{((DateTime)col).ToString("yyyy-MM-dd HH:mm:ss")}\""; | |
case "System.Byte[]": | |
return "0x" + BitConverter.ToString((byte[])col).Replace("-", ""); | |
} | |
return col; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment