Storing images in SQL Server with RIA Services - by Peter Kuhn (@Mister_Goodcat)

In the Silverlight forums people frequently ask for help with storing images in their databases using RIA Services. Even though this looks like a pretty common thing to do, it is far from being straight forward, and searching the web does not seem to produce any good results (or I'm just doing it wrong). So I decided to write this quick walk-through of how to do that. This post describes all steps and possible pitfalls to create a complete application for this from scratch, from the database to the UI.

Table of contents:


  1. Preface
  2. Setting up the project
  3. Creating the model
  4. Setting up the image entity
  5. Setting up the image data entity
  6. Setting up the relation
  7. Creating the database
  8. Problems with the database generation/rework
  9. Creating the domain service
  10. Downloading MVVM Light with NuGet
  11. Creating a simple client UI
  12. Extending the client side model
  13. Conversion of the images
  14. The view model
  15. Loading the available images
  16. Loading the selected image's data
  17. Deleting images
  18. Adding new images
  19. Further considerations
  20. Potential problems
  21. Summary and source code download



Preface
I am not a DBA. Those DBAs I know frown upon things like storing images as blob data in the database. The preferred solution everybody seems to recommend is to only store the meta data in your database and link that to a file in the file system. But still, I did come across situations where I had to design a system like that, for example if a customer had a demand for it out of whatever reasons. Also, it's not true that blob storage in the database is worse than using the file system in any case. If you are interested in more details on the topic, I recommend the following report from Microsoft Research: To blob or not to blob? It claims that for objects of size 256 KBytes or lower storing the binary data in the database has clear advantages over the file system, for sizes of 1 MB or more the file system is a better choice. Inside that range, it depends on the scenario. That report is from 2006 and I very much believe that the situation has not worsened for the database storage since that time.

So, whether the way provided here is suitable for you or not solely depends on your project environment and own research, I don't make any recommendations on this. I also will not make any performance optimizations or similar in this post, it is just meant as a demonstration of how the basic mechanism works, with focus on the client side and middleware.




Read More from: Original Source


Post Contributed by: Kunal Chowdhury

Monday, March 07, 2011


Kunal is the Site Admin and Contributor of Silverlight-Zone. He is a Software Engineer, Microsoft Silverlight MVP, Code Project Mentor and a Code Project MVP. He is also an active Author in SilverlightShow.net and a speaker in various community events. He works on Microsoft Platform and very passionate about Silverlight technology. He started his career in 2007 and achieved various awards during his professional life.

He shares his findings in his personal blog: http://www.kunal-chowdhury.com and he also tweets at: @kunal2383.

.NET 4.5 (3) 3D (14) AdMob (1) Adobe (5) Agile (3) Amazon (1) Android (26) Animation (38) AntiVirus (1) API (2) Apollo (1) Apple (3) ASP.Net (6) AsyncCTP (8) Authentication (11) AVG (1) Award (4) Azure (44) Balder (2) Bing (43) Blend (152) Book (12) Build (18) C# (4) Cacoo (1) Catel (1) Ch9 (42) Clinch (2) Cloud (7) CodeMagazine (7) CodePlex (20) CodeProject (163) Coding4Fun (15) COM (12) ComponentOne (6) Control (55) Controls (5) Cookbook (2) CRM (1) Crud (4) CSS (11) CSS3 (7) CWC2011 (1) Database (51) Delphi (1) DependencyInjection (1) DevComponents (7) DevCurry (2) DevTools (1) Digg (1) DigitalRune (1) DirectX (6) dotNet (3) DotNetCurry (5) DotNetNuke (3) DropBox (4) eBook (17) Encoder (1) EntityFramework (5) Events (18) Exam (13) Excel (1) Exchange (1) Expression (75) ExpressionDesign (4) ExpressionWeb (1) Facebook (21) Fiddler (2) Flash (4) Flex (2) Flickr (3) FSharp (1) Game (65) GitHub (1) Giveaway (4) Google (17) GPS (3) Graphics (1) GZip (1) Hack (1) HowTo (1) HTML (116) HTML5 (80) IE (12) IE10 (2) IE9 (1) IIS (2) Illustrator (1) ImagineCup (1) Infragistics (16) Interview (2) iOS (9) iPad (4) iPhone (9) IronPython (1) JavaScript (38) Jounce (8) jQuery (10) JSON (20) JustCode (1) KendoUI (1) Kindle (1) Kinect (22) Knockout (1) Library (2) LightSwitch (308) LightSwitchTutorial (28) Linq (22) Linux (1) Localization (1) Lumia (26) Mac (4) Mango (455) MCPD (1) MediaElement (1) MEF (23) Metro (335) Mindscape (3) MIX11 (13) ModernUI (47) Mono (1) Moonlight (1) MSDN (14) MSEXP (46) MultiTouch (1) MVC (5) MVC3 (1) MVP (7) MVPChat (1) MVVM (282) NESL (5) News (114) Ninject (2) Nokia (49) NuGet (4) NUnit (1) NVidia (1) oAuth (2) oData (50) Office (1) Office365 (1) OneNote (1) OOB (21) Opus (1) Outlook (1) PDC2010 (8) PDF (4) Performance (43) PhoneGap (31) Photoshop (6) PHP (2) Physics Library (7) Picasa (1) PInvoke (3) PivotViewer (23) Poll (1) PowerPoint (2) PowerShell (2) Prism (37) Prism4 (12) Programming Languages (1) PSD (1) PUG (4) Python (1) RavenDB (1) ReactiveExtension (7) RegEx (1) ReSharper (3) Rest (5) RIA (27) RIAServices (44) Ribbon (3) RichTextBox (1) RSS (10) Ruby (1) Samsung (2) Scrum (3) Security (18) SevenDrops (1) SharePoint (30) Silverlight (1947) Silverlight3 (5) Silverlight4 (162) Silverlight5 (245) Silverlight6 (4) SilverlightBehavior (47) SilverlightCream (36) SilverlightShow (135) SilverlightTV (13) SilverlightZone (26) Sketchflow (14) SkyDrive (16) Skype (8) SLSpy (2) SMF (1) SoapUI (1) Socket (9) SQL (65) SQLCE (38) SQLite (2) sqllite (2) StackOverflow (1) Sterling (6) Storage (1) Style (58) Surface (12) SVG (2) Sync (1) syncfusion (2) Tango (1) TCP (2) TeamPulse (9) TechEd (1) Telerik (283) telerik wpf (1) TelerikMetro (25) Testing (7) TFS (2) Theme (30) Thread (1) Tips (464) Toolkit (49) Tools (4) Training (3) TrainingKit (2) Trigger (6) Troubleshooting (1) Tutorial (326) Twitter (24) TypeMock (1) TypeScript (4) UDP (2) UnitTesting (9) Unity3D (2) Validation (16) VB (5) Video (105) VideoTutorial (71) Visual Studio 2011 (35) VisualStudio (194) VisualStudio11 (2) VisualStudio2011 (36) VisualStudio2012 (36) VLC (1) VMWare (1) VSM (6) VTD (1) WCF (118) Win8 (787) Win8Dev (320) win9 (1) Windows (72) windows 8 (1) Windows Phone (79) Windows7 (2) Windows8 (679) WindowsBlue (7) windowsphone (10) WindowsStoreApp (97) Winform (1) WinHost (1) WinJS (3) WinRT (413) WMV (1) WordPress (3) WP (780) WP7 (2950) WP7.5 (61) WP7.8 (15) WP7Contrib (18) WP7Dev (1563) WP7Exam (1) WP7Toolkit (10) WP8 (240) WP8Dev (235) WPDev (1112) WPF (246) wpmwp7 (1) XAML (654) XAP (10) XBox (11) XML (5) XNA (104) XPG (4) XPS (1) YouTube (7) Zune (5)

The Site has been hosted by Kunal Chowdhury   © 2011

Back to TOP