简体   繁体   English

如何将图像类型添加到EF4 Code First Entity?

[英]How can I add an Image type to an EF4 Code First Entity?

How can I add an Image type to an EF4 Code First Entity? 如何将图像类型添加到EF4 Code First Entity? I need to add a column for thumbnail images. 我需要为缩略图添加一列。

public Image Thumbnail { get; set; }

Thanks! 谢谢!

Images are represented as binary in EF 4 图像在EF 4中表示为二进制

http://thedatafarm.com/blog/data-access/sql-server-2008-data-types-and-entity-framework-4/ http://thedatafarm.com/blog/data-access/sql-server-2008-data-types-and-entity-framework-4/

You will need to do something like this 你需要做这样的事情

public Binary Thumbnail {get; set}

Then convert the image to binary 然后将图像转换为二进制

This reference will help you with the image to binary conversion http://www.dotnetspider.com/resources/6150-Convert-Image-binary-format.aspx 此参考将帮助您进行图像到二进制转换http://www.dotnetspider.com/resources/6150-Convert-Image-binary-format.aspx

public System.Data.Linq.Binary Thumbnail {get; set}

对于那些想知道Binary类型在哪里的人,我也相信你可以使用byte[]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM