[英]How to read blob data from SQL Server Image field using Dapper?
I need to read blob data into a memory stream from an Image type column from an SQL Server database. 我需要从SQL Server数据库的“图像类型”列中将blob数据读取到内存流中。 How can I do this using Dapper?
如何使用Dapper执行此操作?
I was reading the Dapper manual but was unable to find information about this. 我正在阅读Dapper手册,但找不到有关此信息。
UPDATE: I need to read the data from the database (from a query). 更新:我需要从数据库(从查询)中读取数据。 All the links suggested so far has information about how to store the blob in the database.
到目前为止,所有建议的链接都包含有关如何在数据库中存储Blob的信息。
Figured it out. 弄清楚了。 The result dynamic type is a byte[].
结果动态类型是byte []。
var row = con.QueryFirst("SELECT BLOBFIELD FROM TABLE WHERE ID = 1");
byte[] bytes = drawings.BLOBFIELD;
using (var stream = new System.IO.FileStream(@"C:\Temp\Test.dat", System.IO.FileMode.CreateNew))
stream.Write(bytes, 0, bytes.Length);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.