430 likes | 576 Views
ASP.NET 3.5 SP1 Dynamic Data, Entity Framework and Data Services. Gill Cleeren Microsoft Regional Director /MVP Ordina Belgium www.snowball.be – gill.cleeren@ordina.be With the help of Kurt Claeys MVP Connected Systems. General agenda. ASP.NET Dynamic Data AJAX History
E N D
ASP.NET 3.5 SP1Dynamic Data, Entity Framework and Data Services Gill CleerenMicrosoft RegionalDirector/MVPOrdina Belgium www.snowball.be – gill.cleeren@ordina.beWith the help of Kurt ClaeysMVP Connected Systems
General agenda • ASP.NET Dynamic Data • AJAX History • ADO.NET Entity Framework overview • ADO.NET Data Services
Dynamic data • Introduction • ASP.NET Dynamic Data (using EF) • Scaffolding • Model Metadata • Model Validation • Customization • Field Templates • Page Templates • Custom Pages • Routing • Templating
What is Dynamic Data? • Easily create powerful data-driven web apps • Get a running app in under a minute! • Unleash the power of the schema • Customizable and reusable
The traditional approach • Create your model • Create ASP.NET pages • Add data controls and data source controls • Add validation logic in the page • Issues: • Fair bit of work to get started • Logic lives in the wrong place • Ignores valuable schema information • Reuse and customization is difficult
The Dynamic Data approach • Create your model • Instantly get a fully functional app! • Customize the app piece by piece: • Model • Fields • Pages • Routes
Scaffolding • Data-driven web application • Full CRUD • Templated • AJAX • Extensible
Demo Scaffolding
Model metadata • Metadata on model drives the behavior • Default metadata inferred from schema • Data types and relationships • Required fields, string length, … • Add additional metadata • Validation • Field labels and descriptions • Partial methods
Demo Model Metadata
Validation • Validation • Range • Regular Expression • Required • String Length • Model Validation
Demo Validation
Customizing pages • Page templates • Affect shared behavior across tables • Custom pages for individual tables • Choose the column set • Customize the rendering
Customizing the fields • Fields are rendered using templates • Selected based on field data type • Handle rendering, data binding and validation • Template selection can be overridden • Simple ascx files that can easily be reused across projects
Demo Customization
Routing • Determines how external URLs map to application pages • New ASP.NET feature • Also used by ASP.NET MVC
Demo Routing
Templating • Enhance Existing Controls • GridView • ListView • FormView • DetailsView • Centralized Field Definitions • No repetitive code • Dynamic Controls • DynamicField • DynamicControl • DynamicDataManager • DynamicValidator
Demo Templating
AJAX History • ASP.NET Ajax History
History Back Button History Point #1 History Point #2
AJAX History • Take advantage of browser… • Back/Forward Buttons • Bookmarks • Server-Side • UpdatePanel • ScriptManager • Client-Side • Sys.Application • ScriptManager
Demo AJAX History
Agenda • ADO.NET Entity Framework overview
ADO.NET Data Services • Introduction: Data in the web • ADO.NET Data services • Query syntax • Creating Data Services • Addressing options • Pseudo-Members • Query Options • Clients
Data in the Web HTML + Javascript DLL + XAML Mashup UI Data (XML,JSON,…) Data (XML,JSON,…) Data (XML,JSON,…) Data Feeds AJAX Applications Silverlight Applications Online Services Mashups
Model and Operation Semantics • Underlying data model • Entity Data Model • Entities Resources • Associations Links • Operation semantics • Usual mapping of HTTP methods • GET retrieve resource • POST create resource • PUT update resource • DELETE delete resource
URL Conventions • Addressing entities and sets • Presentation options
Demo Accessing the data
Creating Data Services HTTP • Create services directly from Visual Studio • Various data sources • Entity Framework • LINQ providers • Model-driven • Structural description in Entity Data Model • Metadata shapes service Hosting/HTTP listener Service Runtime IQueryable [+ IUpdatable] Data Access Layer Entity Framework Custom LINQ provider Relational database Other sources
Demo Creating the Data Service
Addressing Pseudo-Members • $metadata • AdventureWorks.svc/$metadata • $value • AdventureWorks.svc/Customers(1)/FirstName/$value • $batch • AdventureWorks.svc/$batch
Query Options • Ordering • $orderby [asc | desc] • Paging • $skip • $top • Filtering • $filter • Eager-Loading • $expand
Demo Advanced quering
Clients Data Service
Modern Data-Driven Web Apps • AJAX integration • AJAX-friendly JSON format in services • Javascript library that integrates with the ASP.NET AJAX toolkit • Silverlight support • .NET programming model for data services • Object based, LINQ enabled API • Code-gen entity types from metadata
"Traditional" Applications • Web applications • Data services client can be used in ASP.NET • ASP.NET data source control for accessing remote services • Desktop applications • Fully-featured .NET client library • Same API in desktop and Silverlight environments
Demo Console app using Data Services
Summary • Dynamic data • Easy scaffolding • Up and running in no time • Very customizable • Ajax History • Really needed • Data services • Easy way for retrieving data • Client dev made easy through proxies
ASP.NET 3.5 SP1Dynamic Data, Entity Framework and Data Services Gill CleerenMicrosoft RegionalDirector/MVPOrdina Belgium www.snowball.be – gill.cleeren@ordina.beWith the help of Kurt ClaeysMVP Connected Systems