SQL Server to C# Datatype mapping (help)

  • trying to find the SQL Server to C# Datatype mapping.

    i have links to .NET datatypes for SQL to System.Data.SqlDbType and SQL to System.Data.SqlTypes but looking to map SQL Datatypes to C# Datatypes.

    any suggestions or links would be appreciated.

    thx

    Brian Lockwood

    President

    LockwoodTech Software

    Brian Lockwood
    President
    ApexSQL - SQL Developer Essentials

    http://www.apexsql.com/blog

    Stand up for an Independent SQL Community - be Informed

  • Maybe I am confused, the names are very easy to see how they relate directly to SQL from C#. Maybe I am misunderstanding what you are after. Can you explain a bit better?

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • quote:


    Maybe I am confused, the names are very easy to see how they relate directly to SQL from C#. Maybe I am misunderstanding what you are after. Can you explain a bit better?

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)


    I think you are thinking of .NET datatypes (i.e. sqldbtype or sqltypes).

    There is no clear match to many types from SQL to C#, like what does timestamp map to? I think C# type object but I am not sure. but rather than discuss the similarity in types do you have a link to a mapping or can you provide mapping here?

    here are examples:

    TinyInt -> byte (tinybit is 8 bits)

    SmallInt -> short (16 bits)

    Int -> int (32 bits)

    NText -> string

    NVarChar -> string

    Binary -> object

    Real -> float

    Brian Lockwood

    President

    LockwoodTech Software

    Brian Lockwood
    President
    ApexSQL - SQL Developer Essentials

    http://www.apexsql.com/blog

    Stand up for an Independent SQL Community - be Informed

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply