Picking a Silverlight Data Access Layer

3,694 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
3,694
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Picking a Silverlight Data Access Layer

  1. 1. Picking a Data Layer<br />For Silverlight<br />
  2. 2. Shawn Wildermuth <br />shawn@agilitrain.com<br />http://agilitrain.com<br />C# MVP, MCSD, INETA Speaker<br />Silverlight Insider, CSD Insider, Data Insider<br />Book Author <br />Pragmatic ADO.NET<br />MCTS Training Kit (Exam 536)<br />MCPD Training Kits (Exams 547, 548 & 549)<br />Windows Phonebook (Upcoming)<br />Silverlight Architecture (Upcoming)<br />Silverlight Tour (www.silverlight-tour.com)<br />Who Am I?<br />
  3. 3.
  4. 4. No Data Stack in Silverlight<br />ADO.NET, EF, L2S, etc. don’t exist on client<br />Must use service layer to access data<br />Data Access in Silverlight<br />
  5. 5.
  6. 6. Pros<br />Well-known Technology<br />Hard Contracts on Server<br />Reusability<br />Open Transport format (SOAP)<br />Cons<br />Higher Maintenance Cost<br />API Bloat<br />Manual Client-side Change Management<br />Lack of Client-Side Query Definition<br />No Support for Validation Code<br />Web Services<br />
  7. 7. Web Service Demo<br />
  8. 8. Pros<br />Hard Contracts<br />Well-known Technology<br />Reusability<br />Open Transport format (JSON/POX)<br />Cons<br />Higher Maintenance Cost<br />Manual Client-side Change Management<br />Lack of Client-Side Query Definition<br />No Support for Validation Code<br />REST Services<br />
  9. 9. REST Demo<br />
  10. 10. Our Apps Still Need Data…<br />Web Services are a good approach<br />But we end up adding new queries for every request <br />The Problem…<br />public class MyWebService : System.Web.Services.WebService {<br /> [WebMethod]<br /> public List<Customer> GetCustomers() {<br /> return ctx.Customer.ToList();<br /> }<br /> [WebMethod]<br /> public List<Customer> GetCustomersByContactFirstName() {<br /> return ctx.Customer.OrderBy(c => c.FirstName).ToList();<br /> }<br /> [WebMethod]<br /> public List<Customer> GetCustomersByLastPurchaseDate() {<br /> return ctx.Customer.OrderByDescending(c => c.LastPurchaseDate) <br /> .ToList();<br /> }<br />}<br />
  11. 11. Support Queryable Endpoints<br />Apps should be able to shape the data themselves<br />Secure…but only as secure any web data can be<br />But not expose the database over the web<br />WCF Data Services!<br />The Answer…<br />
  12. 12. Pros<br />Client-defined Query Definitions<br />Including Eager Loading and Projections<br />Client-side Change Management<br />Server-side Batching/Tx Support<br />Open Data Format (OData)<br />Cons<br />Soft Contracts<br />Coarse Grained Security<br />Manual Validation Code<br />WCF Data Services<br />
  13. 13. WCF Data Services Demo<br />
  14. 14. Problem<br />Simplify N-Tier Silverlight Development<br />Empower Same Code to Run on Client and Server<br />Better Integration for VS-centric projects<br />Similar to a Hybrid of Data Services and WCF<br />WCF RIA Services<br />
  15. 15. WCF RIA Services (2)<br />During Build<br />Data Access<br />Layer<br />RIA Services<br />(Domain Service)<br />Silverlight App<br />(Domain Service)<br />Code and Validation Attributes<br />Code and Validation Attributes<br />DB<br />
  16. 16. Pros<br />Client-defined Query Definitions<br />Client/Server Code Sharing<br />Shared Validation Code/Attributes<br />Wizard-based Setup<br />Attribute Based Authorization<br />Client-side Authorization Support<br />Mix of Hard and Soft Contracts<br />Cons<br />Model Changes Require Manual Coding<br />Closed Transport Format<br />Problems in Large Projects<br />Both ends must exist in same VS Project<br />No Support for Client-defined Eager Loading<br />No Support for Projections<br />Mix of Hard and Soft Contracts<br />WCF RIA Services<br />
  17. 17. Web Service Demo<br />
  18. 18. Links:<br /><ul><li>My Blog:
  19. 19. http://wildermuth.com
  20. 20. Presentation and Code Available There
  21. 21. Silverlight Tour:
  22. 22. http://silverlight-tour.com
  23. 23. http://agilitrain.com</li></ul>Questions?<br />

×