Post on 18-Oct-2014
description
ASP.NET Dynamic Data
Scott HunterProgram ManagerMicrosoft Corporation
PC30
Session Objective(s) Understand the ASP.NET data strategy Understand the ASP.NET Dynamic Data feature
Key Takeaways Support for WebForms continues Support for MVC coming Model driven development across
multiple presentation layers
Session Objectives And Takeaways
An easy powerful way to build a data-driven websites Allows you to get started quickly using scaffolding UI can be completely customized
through templates and pages Validation and business rules specified
on data model flow through to UI Allows flexible URL routing, based on data schema and
separate from the physical page structure of the site New dynamic controls make scenarios like sorting, paging,
editing and filtering remarkably easy to implement Available now in .NET Framework 3.5 SP1!
What Is Dynamic Data?
Dynamic Data At A Glance
demo
Scaffolding
// Global.asax: Application_Startmodel.RegisterContext (typeof(NorthwindDataContext), new ContextConfiguration() { ScaffoldAllTables = true });
// WARNING: This enables scaffolding for every table in the model. To enable scaffolding on a per-table or per-column basis, you can use attributes on the model:
[MetadataType(typeof(ProductMeta))] public partial class ProductMeta[ScaffoldTable(true)] {public partial class Product [ScaffoldColumn(true)]{ public object UnitPrice { get; set; }
… }}
Routing
// Global.asax: Application_Start
RouteTable.Routes.routes.Add (new DynamicDataRoute("{table}/{action}.aspx") { Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }), Model = model});
RouteTable.Routes.routes.Add (new DynamicDataRoute("{table}/List.aspx") { Action = PageAction.List, ViewName = "List", Model = model});
RouteTable.Routes.Add(new DynamicDataRoute("MyCategoryDetail/{CategoryID}") { Model = model, Table = "Categories", Action = "Details" });
Scaffolding And Routing
demo
Dynamic Data provides UI customization at many levels (from least to most control)
UI Customization
PageTemplates
FieldTemplates
UIHint/DataType on Model
CustomPages
UIHints on DynamicField/DynamicControl
Allow customization of columns using template based controls Based on the type of the column Source code for standard templates is provided Can be overriden with DataType and
UIHint attributes or properties Easy to create
Implement method to set and get values
Field Template Controls
DynamicDataManager GridView, DetailsView
DynamicDataField ListView, FormView
DynamicControl LinqDataSource, EntitiesDataSource
DynamicControlParameter DynamicQueryStringParameter
DynamicValidator DynamicFilter (UserControl), FilterRepeater
Dynamic Data Controls
UI Customization Demo
demo
Scenario: Reduce code in existing pages Validation
Move validation to data model instead of in individual pages. Change in one place affects entire site
Field Templates Add custom controls in one place
instead of in each of your pages Enable custom controls on model
Use In Existing Pages
Use In Existing Pages
demo
Support for more data access layers ADO.NET Data Services (formerly Astoria) Custom Business Logic Layer
Field Templates URL, E-mail, and Enumeration
Entity Templates Automatic templates for ListView, FormView Templates based on Entity instead of Field
Inheritance Support (EF and Linq2SQL) QueryBlock
Rich Declarative Linq Expressions Rich Filtering
Attributes Templates
MVC Support
Dynamic Data Futures
BusinessLogicLayerDataSource ObjectDataSource that returns IQueryable Support new DataProviderModel
Entity Framework Linq to SQL Custom
Query Block BusinessLogicDataSource/LinqDataSource/
EntityDataSource Declarative Linq Expressions And and Or Range and Contains Custom
Business Logic And Declarative Linq Queries
Business Logic Layer And Query Block
demo
Make building data-driven Web apps easy Ruby on Rails
Dynamic Data and MVCScaffolding, templates and data validation
Support for abstract data-layerRemoves need for specific DL (SQL, entities ..) Allows scaffolding of objects
Keeps MVC conceptsUses HTML helpersTestable
MVC
MVC
demo
Breakout Sessions/Chalk Talks PC21 – ASP.NET MVC PC30 – ASP.NET Dynamic Data PC31 – ASP.NET and Jquery PC32 – ASP.NET Ajax Futures PC33 – Microsoft Visual Studio: Easing ASP.NET Web PC41 – ASP.NET Cache Extensibility TL07 – Developing Applications Using Data Services TL14 – Introducing Velocity TL20 – Entity Framework Futures TL48 – Microsoft Visual Studio: Web Development Futures TL56 – Velocity Internals ES15 – Deploying Web Applications with Microsoft Internet
Information Services 7.0 and the Web Deployment Tool
Related Content
http://www.asp.net/dynamicdata http://www.codeplex.com/aspnet
http://blogs.msdn.com/davidebb/ http://blogs.msdn.com/marcinon/ http://blogs.msdn.com/scothu/ http://weblogs.asp.net/scottgu http://www.hanselman.com/blog/
Resources
Evals & Recordings
Please fill
out your
evaluation for
this session at:
This session will be available as a recording at:
www.microsoftpdc.com
Please use the microphones provided
Q&A
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market
conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.