17.07.2015 Views

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 4: <strong>FILESTREAM</strong> with Entity Framework and LINQ to <strong>SQL</strong>Take a look at the mapping <strong>of</strong> the ItemImage column; it is a <strong>FILESTREAM</strong> column butit is mapped to the Binary data type. EF does not understand <strong>FILESTREAM</strong> values. It sees<strong>FILESTREAM</strong> columns as VARBINARY(MAX) data type values.<strong>The</strong> next step is to create a mapping for the stored procedure we created for saving items.Click on the Map Entity to Functions button on the left side <strong>of</strong> the Mapping Detailswindow, and select the stored procedure from the drop-down list provided for the insertoperation (Figure 4-7).Figure 4-7:Creating a mapping for the stored procedure.With this, we are done with the mapping and it is time to go ahead and write the codethat adds a new item into the table using EF.141

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!