I want to show the images stored in my database in my View.
I have a field "deliverable_image" from the type "longblob" in my mysql database.
In my controller:
public ActionResult Show( int id )
{
var imageData = repository.GetAllImages();
return File( imageData, "image/jpg" );
}
Repository:
public IQueryable<byte[]> GetAllImages()
{
return from deliverable in entities.deliverables
orderby deliverable.deliverable_image
select deliverable.deliverable_image;
}
View:
<img src='<%= Url.Action( "Show", "Deliverable", new { id = ViewData["DeliverableID"] } ) %>' />
But in my controller I get the error:
cannot convert from 'System.Linq.IQueryable' to 'string'
Does anybody knows how I can fix this?