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

我只是一个虾纸丫 提交于 2019-12-06 01:52:21

问题


How can I add an Image type to an EF4 Code First Entity? I need to add a column for thumbnail images.

public Image Thumbnail { get; set; }

Thanks!


回答1:


Images are represented as binary in EF 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




回答2:


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

For those wondering where the type Binary is located, also i belive you can use byte[]



来源:https://stackoverflow.com/questions/4156424/how-can-i-add-an-image-type-to-an-ef4-code-first-entity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!