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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 5: <strong>FILESTREAM</strong> with ASP.NET and Silverlightthe project, select Add | New Item… | Interface) with the name IItemData. At the top<strong>of</strong> the code file, import the System.IO and System.ServiceModel namespaces. <strong>The</strong>definition <strong>of</strong> the IItemData interface is shown in Listing 5-17.[ServiceContract()]Public interface IItemData{[OperationContract()]MemoryStream GetItemImage(string itemID);}Listing 5-17:IItemData interface definition.We now need to modify the DataAccess.ItemData class to implement this newinterface. First, add a reference to the new ServiceInterfaces project in the DataAccessproject. <strong>The</strong>n, modify the definition <strong>of</strong> the ItemData class as shown in Listing 5-18. Nochange is required, other than to write the interface name, because the ItemData classalready implicitly has a GetItemImage() method with the correct signature.Public class ItemData : ServiceInterfaces.IItemData{/* Other code ommitted for brevity */}Listing 5-18:ItemData class implements IItemData interface.Creating the WCF service hostFor this basic lab, we will self-host a WCF service in a console application. In a real-worldscenario, you might consider creating a Windows Service or hosting the WCF serviceunder IIS.212

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

Saved successfully!

Ooh no, something went wrong!