- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个名为 Attachment
的 POCO 类,它映射到 SqlServer 中的一个表,其中有一个 VarBinary(max) 字段。该字段包含文件。
POCO类看起来像这样
public class Attachment
{
public string AttachmentId { get; set; }
public string AttachmentTypeId { get; set; }
public string Title { get; set; }
public string Text { get; set; }
public Binary Data { get; set; }
}
映射看起来像这样
modelBuilder.Entity<Attachment>().Property(a => a.Data).HasColumnName("col_data");
但是映射会抛出错误
The type 'System.Date.Linq.Binary' must be a non-nullable value type in order to use it as a parameter 'T'
如果我使用字节数组,映射工作正常,但这似乎在通过的过程中破坏了数据。
数据库中的文件有一个初始二进制字符串,如:-
0x504B0304140008000800027923400000000000000000000000001F000000
我认为这是一个 JPG 文件。任何帮助将文件从数据库中取出的任何帮助将不胜感激。
最佳答案
Binary
数据类型仅适用于 Linq-to-Sql。 EF 无法使用它。 EF 的正确数据类型是字节数组 (byte[]
)。
关于c# - EF4 将 varbinary(max) 映射到二进制 - 代码优先错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8757460/
我创建了一个表来插入我的应用程序的所有文档。这是一个简单的表(我们称之为 DOC_DATA),它有 3 个字段:DOC_ID、FileSize、Data。数据是 varbinary(max)。 然后我
我有一个数据库,该数据库被设置为对 varbinary(max) 字段上的音频文件使用 blob FileStream。它的大小已经增长到 80GB 以上,我面临着性能问题。 环顾四周后,我发现我的平
在 SQL Server 2008 中从 varbinary(MAX) 字段(不使用 FileStreams)读取部分二进制数据的最有效方法是什么? 将数据写入列时,T-SQL 中可以使用 VarBi
我正在尝试将存储在 CONTEXT_INFO 中的 nvarchar 转换回。 declare @LanguageCode nvarchar(6) = 'en'; declare @binvar va
我正在尝试转换回存储在 CONTEXT_INFO 中的 nvarchar。 declare @LanguageCode nvarchar(6) = 'en'; declare @binvar varb
我有一张像: create table tbl ( id int, data image ) 发现栏目data尺寸非常小,可以存储在varbinary(200) 所以新表将是, create
我在 SQL 中有一个 varbinary 列,我希望该列始终是唯一的。但是,我看到 SQL 不允许在 varbinary 列上创建唯一约束。 是否有任何解决方法来确保这种唯一性?也许通过使用其他类型
有人请解释为什么选择 len(0x0a000b) 返回 3? len 计算字节数吗?为什么 select left(0x0a000b, 1) 什么都不返回?我期望 0x0a(如果 len 计算字节).
我将图像存储在数据库中的 varbinary(max) 字段中。 我正在尝试在我的表单上显示图片。我尝试了很多不同的方法,但没有显示出来。 这是我的代码: //I am adding an image
我们面临一个非常奇怪的问题。 当表列如下时,我们的 mssql 2008 R2 数据库中有一张表: 用户 ID - int 用户名 - varbinary(256) 用户类型 - int 并且 use
我正在尝试将 MSSQL 数据库移植到 MariaDB,并且遇到了使用 varbinary(max) 创建表的情况: `definition` VARBINARY(max) NULL DEFA
如何在 varbinary 中获取特定范围的字节数据? 例如长度 varbinary数据是 128,我只想得到 15-19 个字节。 最佳答案 SELECT SUBSTRING(VarbinaryCo
我正在使用以下命令将 .jpg 插入到 SQL Server 2012 中的 varbinary(max) 列中: INSERT INTO Employees VALUES(5, (SELECT *
基本上,我试图给用户一个特定的密码,以便我可以在系统上测试某些功能,因为我只有我们的管理员帐户,我不能玩,我只是选择一个随机帐户,以便我可以进行测试。所以这是我的更新尝试: UPDATE dbo.Lo
使用 SQL 2005 我有一个包含 5 列的表格 ID - int Param - smallint Data1 - image Data2 - image Data3 - image 图像大小可以
我想升级表中的所有列,我的目标是从要更新的行中检索一列然后更新它,例如: update works set encrpyted_item_no = (CAST(RTrim(( select u
我有一些 varbinary 数据存储在 MS Sql Server 2005 的表中。是否有人有将查询作为输入的 SQL 代码(假设查询保证返回单列 varbinary)并将字节输出到磁盘(每行一个
这个问题已经有答案了: Convert integer to hex and hex to integer (16 个回答) 已关闭10 年前。 这几乎是一个菜鸟问题,但我找不到解决方案。 我正在使用
我们使用 varchar(255) 在 mysql 中存储“关键字”。我们面临一个问题,即 mysql 会忽略“=”中用于比较目的的所有尾随空格。它确实尊重“like”比较中的尾随空格,但它不允许我们
我设法将 Image 转换为 varbinary 并将其存储在我的数据库中。我一直在尝试将 varbinary 转换为图像,但我在这里遇到了一些麻烦。 首先,我从服务中的数据库中获取二进制文件。
我是一名优秀的程序员,十分优秀!