[英]SQL Server 2008 R2 FILESTREAM using ASP.NET & Entity Framework
I have been searching now for 2 days and still struggling! 我已经搜索了2天,但仍在努力! Any advise would be greatly appreciated!
任何建议将不胜感激!
I am busy creating a web app - an online vehicle trader project. 我正在忙于创建一个Web应用程序-一个在线车辆贸易商项目。
Tech: VS2010, SQL Server 2008 R2, Entity Data Model 4 (EF), SQL Filestream For Images. 技术:VS2010,SQL Server 2008 R2,实体数据模型4(EF),用于图像的SQL文件流。
I have my filestream setup correctly and can upload and download images ( varbinary(MAX)
). 我的文件流设置正确,可以上传和下载图像(
varbinary(MAX)
)。
My problems/questions are: 我的问题是:
I have link in a data grid that will download the image. 我在数据网格中有链接,该链接将下载图像。 I don't want to download, I need to display the actual image in the grid.
我不想下载,我需要在网格中显示实际图像。
All of the above is done using ADO.NET, how can this be integrated into EF? 以上所有操作都是使用ADO.NET完成的,如何将其集成到EF中? My understanding is that EF does NOT support filestream?
我的理解是EF不支持文件流吗? Has this changed in EF4?
EF4中有此更改吗?
Maybe I have this whole thing backwards? 也许我整个事情都倒退了?
Any advise, links to examples would be greatly appreciated! 任何建议,链接到示例将不胜感激!
I am not aware of FILESTREAM support in EF yet but I don't think you really need it. 我还不知道EF中对FILESTREAM的支持,但我认为您并不是真的需要它。 You can just map the ID of the image in EF and use plain SQL to load the image content in the browser.
您可以仅在EF中映射图像的ID,然后使用普通SQL在浏览器中加载图像内容。 This will not be a problem because you never load to eagerly load the image in a web app as it is rendered via a separate URL so you only need the ID.
这不会有问题,因为您无需加载就可以通过单独的URL渲染将图像快速加载到Web应用程序中,因此只需要ID。 The SQL to fetch something by ID is the simplest thing ever so you don't lose any of the EF power.
通过ID来获取内容的SQL是迄今为止最简单的事情,因此您不会失去任何EF功能。 The only problem may be eventual inserts if you have FKs that are related to EF objects but this should be simple enough.
如果您有与EF对象相关的FK,则唯一的问题可能是最终插入,但这应该足够简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.