图像数据类型 SQL Server 2008 C# 数据类型

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9285757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 06:43:24  来源:igfitidea点击:

image data type SQL Server 2008 C# data type

c#sql-server

提问by user1135534

I created a data table

我创建了一个数据表

CREATE TABLE [ProductImages]
(
[ProductImageID] [int] IDENTITY(1,1) NOT NULL,
[ProductImage] [image] NOT NULL
 CONSTRAINT [PK_ProductImages] PRIMARY KEY CLUSTERED
 (
   [ProductImageID] ASC
 ) 
)

I'm trying to write ProductImages class in C#

我正在尝试用 C# 编写 ProductImages 类

public class ProductImages
{
    private int productImageID;

    public int ProductImageID
    {
        get { return productImageID; }
        set { productImageID = value; }
    }

 // I need to declare property for ProductImage???

}

How do i declare property for ProductImage ?

我如何声明 ProductImage 的属性?

采纳答案by NotMe

public byte[] ProductImage { get; set;} 

Would work... Images are just binary files and you marshal them between SQL Server and your application as the byte[] data type.

会工作...图像只是二进制文件,您可以在 SQL Server 和您的应用程序之间将它们编组为 byte[] 数据类型。

回答by Tim Medora

Use a byte[]in c# and I suggest changing your column type to VARBINARY(MAX). Support for the image data type will be removed in the future.

byte[]在 c# 中使用 a ,我建议将您的列类型更改为VARBINARY(MAX). 将来删除对图像数据类型的支持。