Download presentation
Presentation is loading. Please wait.
Published byAndrea Owen Modified over 9 years ago
1
Developing with WCF RIA Services Quickly and Effectively Nikhil Kothari Software Architect, Microsoft Corporation Blog: http://www.nikhilk.nethttp://www.nikhilk.net Twitter: @nikhilk@nikhilk
2
Agenda Getting started on an application – End-to-end introduction Going beyond the basics – Implementing MVVM/ViewModel – Designing the application logic Tips and guidelines along the way Sneak peek at future possibilities
3
The RIA Services Vision Simplify n-tier data-driven application development A higher level framework on top of existing building blocks – LINQ, Data Access Technologies, WCF, Metadata Provide an application architecture that scales to fit needs of breadth line-of-business applications
4
What would you like to see? http://www.nikhilk.net/RIA-Services-MIX10.aspx Pick a real-world scenario; skip the drag/drop – An example of when UI is not mapped one-to-one with a database table – An example of projections across tables – An example where DAL types are not passed to the client – An example of using a stored procedure – When to use [Invoke] vs. Insert/Update/Delete methods? – How to implement the combobox/lookup table scenario? How to make RIA Services work with MVVM?
5
DEMO An End-to-End Introduction to RIA Services
6
BookClub ApplicationApplication DB Services Data Access Layer AppLogic PresentationLogic Network DomainService Stateless CRUD + App Logic class BookShelfService IQueryable GetBooks() void ShareBook(Book) void UpdateBook(Book) void UnshareBook (Book) Validation, authorization, business rules Data Model class Book DomainContext Stateful view + Bindable Data class BookShelfContext EntitySet Books { get } EntityQuery GetBooksQuery() Entities class Book Data members + Validation Data Model + Metadata + Shared Code DomainService.Query Invoke GetBooks() Compose query, execute, serialize results DomainService.SubmitChanges Authorize, Validate, Execute, Persist var q = Context.GetBooksQuery() Context.Load(q); Context.Books.Add(newBook); Context.SubmitChanges(); Queries and ChangeSets
7
Thinking ViewModel aka MVVM A pattern for separating application behavior out of the user interface Motivation – Facilitate designer/developer workflow, and independent design/development activity – Encapsulate state and operations of application – Improve maintainability – Facilitate testability
8
ViewModel + RIA ServicesApplication Data Model Services, Business Rules View Model App State, Operations, Notifications Presentation XAML, UI Logic <Button Content=“Load” Command=“loadCommand” /> public class BookShelfModel : INotifyPropertyChanged { BookShelfContext _bookShelf; public IEnumerable Books { get; } public void LoadBooks(string) { // use _library to perform search } public class Book : Entity { … } public class BookShelfContext : DomainContext { public EntitySet Books { get; } }
9
Sketching the ViewModel Books SelectedBook (two-way) SelectedBook LoadBooks() LoadMoreBooks() SaveBooks() ShareBook() UnshareBook() EditBook()
10
DEMO Implementing the ViewModel Pattern with RIA Services
11
The Role of DomainServices Encapsulate reusable application logic and expose it as a set of CRUD – Meaningful tasks unique to your application Interesting implementation scenarios – Constraining results – Validation, authorization and business rules – Shaping data – Aggregating data – Caching – Triggering business processes – …
12
Designing DomainServices - Identifying the Tasks GetBooks UpdateBook UnshareBook ShareBook
13
Designing DomainServices - Identifying the Tasks RequestBook GetBooksOfDay SearchBooks GetLatestBooks
14
Designing DomainServices – Presentation Model Types
15
DomainServices + Entities Layering your DomainServices Data Access Layer + DAL Types BookClub ObjectContext Reference DataService BookClub Service BookMemberRequestCheckoutCategory BookInfo IQueryable GetCategories() IQueryable GetBooks() IQueryable SearchBooks() IQueryable GetBooksOfDay() void RequestBook(int bookID) Category Amazon BookShelf Service Book IQueryable GetBooks() void ShareBook() void UnshareBook() void UpdateBook()
16
DEMO Walkthrough of an Interesting DomainService Implementation
17
Recap: Tips and Guidelines Constrain your queries – Parameters, business rules, result limits Define specific operations on your domain service that match your application semantics Use validation to enforce rules, and provide useful user experience – Member, Entity, Operation, Server-only, Async Use authorization to restrict access to data and operations Handle errors – any Load/Submit could fail Separate out reference data to facilitate sharing and optimal loading
18
Recap: Some More Tips Focus on the tasks that define your application – Customize your DomainServices – Group logically related tasks per DomainService Create custom entity types designed for use between client and server when appropriate – Expose sufficient and minimum amount of information – Aggregate, re-shape, project on the server – Consider security, band-width and latency
19
Scaling your DomainServicesAppLogic Databases ADO.NET, ORMs (LTS, EF, …) Lists/Objects Repository (NHibernate, …) Services REST/SOAP (Azure, …).NET Clients Silverlight, Phone, WPF Standards Clients JavaScript Server Rendering HTML, Sitemaps Services SOAP, XML, JSON, OData Unit Test Code
20
DEMO RIA Services + Windows Phone 7
21
Related Talks CL08 – Microsoft Silverlight 4 Business Applications CL50 – Search Engine Optimization for Microsoft Silverlight FT15 – Accessing Data in a Microsoft Connected Web Application EX14 - Understanding the Model-View- ViewModel Pattern RIA Services Meetup at 8pm today in 24001
22
Roadmap and Further Information Bits – Today: Feature-complete RC build that works with SL4 and VS2010 RC – V1: Ship with SL4 on top of.NET 4/VS2010 – Hosters starting to get on-board (eg. DiscountASP, OrcsWeb) More Information – http://silverlight.net/riaservices - RIA Services Online http://silverlight.net/riaservices – Blogs http://www.nikhilk.net http://blogs.msdn.com/brada http://jeffhandley.com
23
Call to Action Get a jumpstart on your next Silverlight-based LOB/data-driven app – RIA Services builds on WCF and Silverlight 4 and provides end-to-end solutions – Takes care of services infrastructure, binding infrastructure Implement well-architected manageable application, and work well for designer/developer workflow – RIA Services is complemented by patterns such as task- centric design approaches and ViewModel
24
Q&A
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.