什么SqlDbType映射到VARBINARY(最大值)? [英] What SqlDbType maps to varBinary(max)?

查看:386
本文介绍了什么SqlDbType映射到VARBINARY(最大值)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么SqlDbType映射到VARBINARY(最大值)? SqlDbType.VarBinary说,这是仅限于8K。 SQL Server文档说,VARBINARY(MAX)都能aprrox存储。 2GB。但是SqlDbType.VarBinary说,这是仅限于8K。

What SqlDbType maps to varBinary(max)? SqlDbType.VarBinary says that it is limited to 8K. SQL Server documentation says that varbinary(max) can store aprrox. 2GB. But SqlDbType.VarBinary says that it is limited to 8K.

推荐答案

SqlDbType.VarBinary长度-1是VARBINARY(MAX)的等值,至少理论上是这样。但问题是复杂一点,因为还有一个类型(而不是枚举值),即<一个href=\"http://msdn.microsoft.com/en-us/library/system.data.sqltypes.sqlbytes.aspx\"><$c$c>SqlTypes.SqlBytes可以使用的。并有<一个href=\"http://msdn.microsoft.com/en-us/library/system.data.sqltypes.sqlfilestream.aspx\"><$c$c>SqlTypes.SqlFileStream它也可以用于 VARBINARY(MAX)类型,当他们有 FILESTREAM 属性。

SqlDbType.VarBinary with length -1 is the equivalent of VARBINARY(MAX), at least in theory. But the problem is a bit more complex, as there is also a type (not an enum value), namely SqlTypes.SqlBytes which can be used. And there is SqlTypes.SqlFileStream which can be used also for VARBINARY(MAX) types, when they have the FILESTREAM attribute.

但问题是,没有这些枚举或类型的覆盖在ADO.Net与 VARBINARY(MAX)工作列,真正的问题:内存消耗。所有这些类型的,在使用时出的最盒子,将创建分配为内存中的单个阵列,这是最好的unperformant值的副本,但作为内容变大就降权是不可能的,因为分配失败使用。我有一对夫妇,显示采用流语义避免内存整个副本的创建来处理ADO.Net VARBINARY(MAX)值的正确方法的文章内容:

But the problem is that none of these enums or types cover the real issue with working with VARBINARY(MAX) columns in ADO.Net: memory consumption. All these types, when used 'out-of-the-box', will create copies of the value allocated as a single array in memory, which is at best unperformant, but as content gets larger becomes down right impossible to use because allocation failures. I have a couple of articles that show the proper way to handle VARBINARY(MAX) values in ADO.Net using streaming semantics that avoid the creation of in-memory copies of the entire content:

  • Download and Upload images from SQL Server via ASP.Net MVC
  • FILESTREAM MVC: Download and Upload images from SQL Server

这篇关于什么SqlDbType映射到VARBINARY(最大值)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆