简体   繁体   English

使用ASP.NET和实体框架的SQL Server 2008 R2 FILESTREAM

[英]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: 我的问题是:

  1. 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. 我不想下载,我需要在网格中显示实际图像。

  2. 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.

相关问题 在ASP.NET中连接到SQL Server 2008 R2错误 - Connection to sql server 2008 R2 error in asp.net 部署使用Asp.Net,C#和Sql Server 2008 R2构建的Web应用程序 - Deploying an Web Application built using Asp.Net,C# and Sql Server 2008 R2 使用SqlParameter实现C#ASP.NET和SQL Server 2008 R2的安全性 - Using SqlParameter for security with C# ASP.NET and SQL Server 2008 R2 ASP.NET MVC3,旨在从SQL Server CE迁移到Server 2008 R2 - ASP.NET MVC3, tyring to migrate from SQL Server CE to Server 2008 R2 asp.net中Windows Server 2008 R2上的PDF缩略图 - PDF Thumbnails on windows server 2008 R2 in asp.net 30秒后在ASP.NET上超时,在SQL Server 2008 R2上没有超时 - Timeout on ASP.NET after 30 seconds, on SQL server 2008 R2 no timeout 如何从asp.net将aspnetdb.mdf附加到SQL Server 2008 R2的本地实例? - How to attach aspnetdb.mdf to local instance of sql server 2008 R2 from asp.net? 存储过程不返回任何数据asp.net sql server 2008 r2 - store procedure don't return any data asp.net sql server 2008 r2 使用SQL Server 2008 R2在ASP.NET C#中创建Crystal Report - Creating Crystal Report in asp.net c# with SQL Server 2008 R2 触发器是否异步(在SQL Server 2008 R2的asp.net命令对象上) - Are triggers asynchronous (on asp.net command object for SQL Server 2008 R2 )
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM