SQL Server data type | CLR data type (SQL Server) | CLR data type (.NET Framework) |
---|---|---|
bigint | SqlInt64 | Int64, Nullable<Int64> |
binary | SqlBytes, SqlBinary | Byte[] |
bit | SqlBoolean | Boolean, Nullable<Boolean> |
char | None | None |
cursor | None | None |
date | SqlDateTime | DateTime, Nullable<DateTime> |
datetime | SqlDateTime | DateTime, Nullable<DateTime> |
datetime2 | SqlDateTime | DateTime, Nullable<DateTime> |
DATETIMEOFFSET | None | DateTimeOffset, Nullable<DateTimeOffset> |
decimal | SqlDecimal | Decimal, Nullable<Decimal> |
float | SqlDouble | Double, Nullable<Double> |
geography | SqlGeography defined in Microsoft.SqlServer.Types.dll Download here:feature pack. | None |
geometry | SqlGeometry defined in Microsoft.SqlServer.Types.dll Download here: feature pack. | None |
hierarchyid | SqlHierarchyId defined in Microsoft.SqlServer.Types.dll Download here: feature pack. | None |
image | None | None |
int | SqlInt32 | Int32, Nullable<Int32> |
money | SqlMoney | Decimal, Nullable<Decimal> |
nchar | SqlChars, SqlString | String, Char[] |
ntext | None | None |
numeric | SqlDecimal | Decimal, Nullable<Decimal> |
nvarchar | SqlChars, SqlString SQLChars is a better match for data transfer and access, and SQLString is a better match for performing String operations. | String, Char[] |
nvarchar(1), nchar(1) | SqlChars, SqlString | Char, String, Char[], Nullable<char> |
real | SqlSingle | Single, Nullable<Single> |
rowversion | None | Byte[] |
smallint | SqlInt16 | Int16, Nullable<Int16> |
smallmoney | SqlMoney | Decimal, Nullable<Decimal> |
sql_variant | None | Object |
table | None | None |
text | None | None |
time | TimeSpan | TimeSpan, Nullable<TimeSpan> |
timestamp | None | None |
tinyint | SqlByte | Byte, Nullable<Byte> |
uniqueidentifier | SqlGuid | Guid, Nullable<Guid> |
User-defined type(UDT) | None | The same class that is bound to the user-defined type in the same assembly or a dependent assembly. |
varbinary | SqlBytes, SqlBinary | Byte[] |
varbinary(1), binary(1) | SqlBytes, SqlBinary | byte, Byte[], Nullable<byte> |
varchar | None | None |
xml | SqlXml | None |
Image Source: http://msdn.microsoft.com/en-us/library/bb386947.aspx
Platform Invoke Data Types
Unmanaged type in Wtypes.h | Unmanaged C language type | Managed class name | Description |
---|---|---|---|
HANDLE | void* | System.IntPtr | 32 bits |
BYTE | unsigned char | System.Byte | 8 bits |
SHORT | short | System.Int16 | 16 bits |
WORD | unsigned short | System.UInt16 | 16 bits |
INT | int | System.Int32 | 32 bits |
UINT | unsigned int | System.UInt32 | 32 bits |
LONG | long | System.Int32 | 32 bits |
BOOL | long | System.Int32 | 32 bits |
DWORD | unsigned long | System.UInt32 | 32 bits |
ULONG | unsigned long | System.UInt32 | 32 bits |
CHAR | char | System.Char | Decorate with ANSI. |
LPSTR | char* | System.String or System.StringBuilder | Decorate with ANSI. |
LPCSTR | Const char* | System.String or System.StringBuilder | Decorate with ANSI. |
LPWSTR | wchar_t* | System.String or System.StringBuilder | Decorate with Unicode. |
LPCWSTR | Const wchar_t* | System.String or System.StringBuilder | Decorate with Unicode. |
FLOAT | Float | System.Single | 32 bits |
DOUBLE | Double | System.Double | 64 bits |
Source: http://msdn.microsoft.com/en-us/library/aa720411(VS.71).aspx
Multiple Data Types Mapping Table
Category | Class name | Description | Visual Basic data type | C# data type | Managed Extensions for C++ data type | JScript data type |
---|---|---|---|---|---|---|
Integer | Byte | An 8-bit unsigned integer. | Byte | byte | char | Byte |
SByte | An 8-bit signed integer.Not CLS-compliant. | SByte No built-in type. | sbyte | signed char | SByte | |
Int16 | A 16-bit signed integer. | Short | short | short | short | |
Int32 | A 32-bit signed integer. | Integer | int | int -or- long | int | |
Int64 | A 64-bit signed integer. | Long | long | __int64 | long | |
UInt16 | A 16-bit unsigned integer.Not CLS-compliant. | UInt16 No built-in type. | ushort | unsigned short | UInt16 | |
UInt32 | A 32-bit unsigned integer.Not CLS-compliant. | UInt32 No built-in type. | uint | unsigned int -or- unsigned long | UInt32 | |
UInt64 | A 64-bit unsigned integer.Not CLS-compliant. | UInt64 No built-in type. | ulong | unsigned __int64 | UInt64 | |
Floating point | Single | A single-precision (32-bit) floating-point number. | Single | float | float | float |
Double | A double-precision (64-bit) floating-point number. | Double | double | double | double | |
Logical | Boolean | A Boolean value (true or false). | Boolean | bool | bool | bool |
Other | Char | A Unicode (16-bit) character. | Char | char | wchar_t | char |
Decimal | A 96-bit decimal value. | Decimal | decimal | Decimal | Decimal | |
IntPtr | A signed integer whose size depends on the underlying platform (a 32-bit value on a 32-bit platform and a 64-bit value on a 64-bit platform). | IntPtr No built-in type. | IntPtr No built-in type. | IntPtr No built-in type. | IntPtr | |
UIntPtr | An unsigned integer whose size depends on the underlying platform (a 32- bit value on a 32-bit platform and a 64-bit value on a 64-bit platform).Not CLS-compliant. | UIntPtr No built-in type. | UIntPtr No built-in type. | UIntPtr No built-in type. | UIntPtr | |
Class objects | Object | The root of the object hierarchy. | Object | object | Object* | Object |
String | An immutable, fixed-length string of Unicode characters. | String | string | String* | String |
Source: http://msdn.microsoft.com/en-us/library/aa720713(VS.71).aspx
No comments:
Post a Comment