对于以下SQL Server数据类型,C#中对应的数据类型是什么?

Exact Numerics

bigint
numeric
bit
smallint
decimal
smallmoney
int
tinyint
money

Approximate Numerics

float
real

Date and Time

date
datetimeoffset
datetime2
smalldatetime
datetime
time

Character Strings

char
varchar
text

Unicode Character Strings

nchar
nvarchar
ntext

Binary Strings

binary
varbinary
image

Other Data Types

cursor
timestamp
hierarchyid
uniqueidentifier
sql_variant
xml
table

(来源:MSDN)

推荐答案

这是SQL Server 2005美元.该表有SQL Server 2008SQL Server 2008 R2SQL Server 2012SQL Server 2014的更新版本.

SQL Server数据类型及其属性.NET框架类似功能

下表列出了Microsoft SQL Server数据类型、System.Data.SqlTypes命名空间中SQL Server公共语言运行时(CLR)中的等效数据类型,以及Microsoft SQL Server中的本机CLR等效数据类型.NET框架.

SQL Server data type CLR data type (SQL Server) CLR data type (.NET Framework)
varbinary SqlBytes, SqlBinary Byte[]
binary SqlBytes, SqlBinary Byte[]
varbinary(1), binary(1) SqlBytes, SqlBinary byte, Byte[]
image None None
varchar None None
char None None
nvarchar(1), nchar(1) SqlChars, SqlString Char, String, Char[]
nvarchar SqlChars, SqlString String, Char[]
nchar SqlChars, SqlString String, Char[]
text None None
ntext None None
uniqueidentifier SqlGuid Guid
rowversion None Byte[]
bit SqlBoolean Boolean
tinyint SqlByte Byte
smallint SqlInt16 Int16
int SqlInt32 Int32
bigint SqlInt64 Int64
smallmoney SqlMoney Decimal
money SqlMoney Decimal
numeric SqlDecimal Decimal
decimal SqlDecimal Decimal
real SqlSingle Single
float SqlDouble Double
smalldatetime SqlDateTime DateTime
datetime SqlDateTime DateTime
sql_variant None Object
User-defined type(UDT) None user-defined type
table None None
cursor None None
timestamp None None
xml SqlXml None

.net相关问答推荐

EGC / 文本元素上的 .NET String.Split

调整小数精度,.net

在 ASP.NET MVC 中我可以在哪里放置自定义类?

为什么 Any() 不适用于 c# null 对象

Environment.TickCount 与 DateTime.Now

.NET 应用程序的链接器状态(又名请先生,我可以有一个链接器2009 年版)

如何让 DateTimePicker 显示一个空字符串?

我什么时候应该在 C# 中使用使用块?

如何退出所有正在运行的线程?

我不了解应用程序域

C#中的T是什么意思?

如何在 C# 中安全地将 System.Object 转换为bool?

绑定到不在列表中的值的可编辑组合框

找不到库 hostpolicy.dll

如何在 C# 中处理 XML

找不到 System.Windows.Media 命名空间?

如何使用 NPOI 读取文件

为 webClient.DownloadFile() 设置超时

System.ServiceModel 在 .NET Core 项目中找不到

在构建事件命令行中放置注释的正确方法?