Skip to content

Instantly share code, notes, and snippets.

@jujiro
Created May 20, 2019 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jujiro/11a1147b79c581a06a5be9a400e5f103 to your computer and use it in GitHub Desktop.
Save jujiro/11a1147b79c581a06a5be9a400e5f103 to your computer and use it in GitHub Desktop.
Sql data type mappings to some basic clr types
public class TypeMapping
{
public Dictionary<string, string> SqlToCSharpMappings = new Dictionary<string, string>()
{
{"BINARY","byte[]"},
{"BIGINT","long?"},
{"BIT","bool?"},
{"CHAR","string"},
{"DATETIME2","DateTime?"},
{"DECIMAL","decimal?"},
{"FLOAT","double?"},
{"IMAGE","byte[]"},
{"INT","int?"},
{"MONEY","decimal?"},
{"NCHAR","string"},
{"NTEXT","string"},
{"NUMERIC","decimal?"},
{"NVARCHAR","string"},
{"REAL","single"},
{"SMALLDATETIME","DateTime?"},
{"SMALLINT","Int16?"},
{"SMALLMONEY","decimal?"},
{"TEXT","string"},
{"TIME","TimeSpan?"},
{"TIMESTAMP","byte[]"},
{"TINYINT","byte?"},
{"UNIQUEIDENTIFIER","Guid?"},
{"VARBINARY","byte[]"},
{"VARCHAR","string"},
{"XML","string"}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment