asp.net 3.5 sp1
DESCRIPTION
ASP.NET 3.5 SP1TRANSCRIPT
.NET 3.5 Enhancements (SP1)
.NET 3.5 Enhancements (SP1)Dave AllenISV Application ArchitectDeveloper and Platform GroupMicrosoft UK
AgendaAgenda
ADO.NET Entity FrameworkADO.NET Data ServicesASP.NET RoutingASP.NET Dynamic Data
ADO.NET Entity FrameworkADO.NET Entity Framework
Another data access technology!?!Not designed to replace what has gone beforeAddresses the OOP versus Relational problem
OOP very well establishedRelational have been around even longerBridging the gap has mostly been a manual taskSome 3rd party solutions, core problem remains
Objects != Relational DataFundamental problem is that relational data and objects in a programming language are NOT the same!
They have different semantics, languages, etc.But both are still needed in most applications
ADO.NET Entity FrameworkADO.NET Entity Framework
Entity Data ModelModels Entities and relationships between those EntitiesHow does it bridge the gap between OOP and Relational
Common type systemInheritanceComplex types
EDM is scoped to just modeling design of application data
Entity FrameworkProvides services for consuming an EDM
Object ServicesEntity Client (EntityConnection, EntityDataReader, etc.)Entity SQLLINQ To EntitiesProvider model for 3rd party databases
Entity Data ModelEntity Data Model
Application modelMapped to a persistence store
Comprised of three layers:Conceptual (CSDL)Mapping (MSL)Storage (SSDL)
Database agnosticNot compiled
Embed as a resourceStore externally
Conceptual
Mapping
Storage
Entity Data Model
DemoDemoEntity Data Model
Entity FrameworkEntity Framework
EDM consumption options:Entity Client
Entity SQLObject Services
Entity SQLLINQ To Entities
Entity ClientEntity Client
Familiar ADO.NET object model:EntityCommandEntityConnectionEntityDataReaderEntity ParameterEntityTransaction
Text-based resultsRead-onlyUses Entity SQL
Entity SQLEntity SQL
• SQL-like query language• Targets conceptual model• Database agnostic
T-SQL
Entity SQL
DemoDemoEntity Client
Object ServicesObject Services
Object materialized queriesObjectContextObjectQuery<T>
Built on top of Entity ClientTwo query options:
Entity SQLLINQ
Runtime services:Unit of workIdentity trackingEager/explicit loading
DemoDemoObject Services
Entity Framework – Service StackEntity Framework – Service Stack
LINQ To Entities
Object Services
Entity SQL
Entity Client
ADO.NET Provider
Entity Framework featuresEntity Framework features
Many to many relationshipsJoin tables ignored by designer in EDMSide-effect, relationships cannot contain dataLINQ supports this via the aggregate functions
InheritanceAllows Entities to be specializedMaps to CLR inheritanceFully supported in queries3 types of inheritance
Table per typeTable per hierarchyTable per concrete type
Entity Framework features (2)Entity Framework features (2)
Entity splittingSingle entity split across multiple tables, something you may do with very large tables
Stored proceduresMost asked question about EFFully supported for CUD, map CUD functions to SPsMainly supported for queries, but doesn’t support composable queries, dynamic SQL within SPs
No metadata available at design-timeWorking against principles of EFDon’t use EF if you do this
Consider using TVF instead of SPs
LINQ to SQL or Entity FrameworkLINQ to SQL or Entity Framework
The case for LINQ to SQLUse an ORM solution where database is 1:1 with Object ModelUse an ORM solution with inheritance hierarchies that are stored in a single tableUse POCO instead of using generated classes or deriving from a base class or implementing an interfaceLeverage LINQ as the way to write queriesUse an ORM solution, but want something that is very performant and where optimization can be achieved, where necessary, through stored procedures
LINQ to SQL or Entity Framework (2)LINQ to SQL or Entity Framework (2)
The case for LINQ to EntitiesWrite applications that can target different database engines in addition to SQL ServerDefine domain models for applications and use them as the basis for the persistence layerUse an ORM solution where classes may be 1:1 with the database or may have a different structure from the database schemaUse an ORM solution with inheritance that may have alternative storage schemes (single table for the hierarchy, single table for each class, single table for all data related to specific type)Leverage LINQ as the way to write queries and have the query work in a database vendor agnostic mannerUse an ORM solution, but want something that is very performant and where optimization can be achieved, where necessary, through stored procedures
Data Service over HTTPData Service over HTTP
HTML + JavaScript
Data (XML, etc)
DLL + XAML
Data (XML, etc) Data (XML, etc)
Mashup UI
Data Feeds
AJAX Applicatio
ns
Silverlight Applicatio
ns
Online Services
Mashups
Data Services todayData Services today
Web Service (ASMX, WCF)
1) GetCustomer(int id)
2) GetCustomers()
3) GetCustomers(string orderBy)
4) GetCustomers(string orderBy, string sortDirection)
5) GetCustomers(string orderBy, string sortDirection, int offset, int count)
6) GetCustomers(string orderBy, string sortDirection, int offset, int count, string filter, string filterValue)
ADO.NET Data ServicesADO.NET Data Services
Data publishing service using a RESTful interfaceJust uses HTTP
Therefore is able to use existing authentication mechanisms, and other infrastructure components such as caching and proxies
Uniform URL SyntaxEvery piece of information is addressablePredictable and flexible URL syntax
Multiple representationsATOMJSONPOX
ADO.NET Data Services (2)ADO.NET Data Services (2)
Exposes an object model (not a database) over the web
Entity Data Model – ADO.NET DS designed to work with EDMLINQ To SQL model, read-onlyCustom IQueryable<T> provider
Operation semantics, mapping of HTTP verbs for CRUD operations
GET – retrieve resourcePOST – create a resourcePUT – update a resourceDELETE – delete a resource
URL ConventionsURL Conventions
Addressing entities and sets
Presentation options
Entity-set /Product
Single Entity /Product(324)
Member access /Product(324)/Name
Link traversal /ProductSubcategory(2)/Product
Deep access /ProductSubcategory(2)/Product(789)/Name
Raw value access /Product(324)/Name/$value
Sorting /Product?$orderby=Name
Filtering /Product?$filter=Color%20eq%20'Black'
Paging /Product?4top=10$skip=30
Inline expansion /ProductSubcategory?$expand=Product
FiltersFilters
Logical operatorsand, or , asc, desc, eq, ne, true, false, gt, ge, lt, le, not, null
Arithmetic operatorsadd, sub, div, mul, mod
String functionsendswith, indexof, replace, startswith, tolower, toupper, trim, substring, substringof, concat, length
Date functionsyear, month, day, hour, minute, second
Math functionsround, floor, ceiling
Type functionsIs, Cast
DemoDemoADO.NET Data Services – Adventure Works
Securing and Customizing Data ServicesSecuring and Customizing Data Services
VisibilityControl visibility per containerRead, Query, and Write options
AuthenticationIntegrates with the hosting environmentASP.NET, WCF, or Custom authentication module
InterceptorsExecute before HTTP GET/PUT/POST/DELETEEnable validation, custom row-level securityMaintain the REST interface
Service operationsAllow you to inject methods into URI if you need to
ClientsClients
Data Service
ASP.NET AJAX ClientASP.NET AJAX Client
DataServiceHTTP
DataModel
Sys.Data.DataService
JSON
ServerClient
ASP.NET AJAX ClientASP.NET AJAX Client
Sys.Data.ActionSequenceSys.Data.DataServiceSys.Data.QueryBuilder
.NET Client.NET Client
DataServiceHTTP
DataModel
DataServiceContext
ObjectModel
ServerClient
DemoDemoSilverlight 2.0 Client - Northwind
Operation BatchingOperation Batching
DataServiceContext
1) Add Entity #12) Update Entity3) Add Entity #24) Delete Entity #15) Delete Entity #2
DataService
POSTPUT
POSTDELETEDELETE
Operations:5 server hits
Without batching
Operation BatchingOperation Batching
DataServiceContext
1) Add Entity2) Update Entity3) Add Entity #24) Delete Entity5) Delete Entity #2
DataService
POST /$batch
Operations:1 server hit
With batching
Operation BatchingOperation Batching
DataServiceContext
1) Get Entity #12) Get Entity #23) Get Entity #3
DataService
Operations:3 server hits
Without batching
GETGETGET
Operation BatchingOperation Batching
DataServiceContext
1) Get Entity #12) Get Entity #23) Get Entity #3
DataService
Operations:1 server hit
With batching
GET /$batch
DemoDemoOperation Batching
ASP.NET RoutingASP.NET Routing
Define your application’s URL entry pointsStatic (/Products/Edit/23)Parameterized (/Blog/{year}/{month} /{day})
Map these URL templates to route handlersGenerate URLs based off your defined route tableCan be leveraged by ASP.NET…
WebFormsMVC (using)Dynamic Data (using)
DemoDemoASP.NET Routing
ASP.NET Dynamic DataASP.NET Dynamic Data
RAD approach to building data driven web appsBased on top of object model
LINQ To SQLEntity Data Model
Data-driven web application ‘scaffolding’Uses the power of the underlying schemaCustomizable through templatesFull CRUD operationsAJAX-enabled
Extend the modelMetadataValidation
ASP.NET – traditional approachASP.NET – traditional approach
Create a data access layerADO.NET (Datasets, Custom Objects, XML, etc.)LINQ to SQL
Created ASP.NET pagesAdd Data Source controlsAdd controls that bind to Data Source controlsAdd validation logic to page
IssuesLots of work up frontDuplication of validation logicDB schema ignored – data validation ends up in UIReuse needs to be thought about – not intuitive
ASP.NET – dynamic data approachASP.NET – dynamic data approach
Create a data modelEntity FrameworkLINQ to SQL
Generate a Dynamic Data applicationCustomize the application
Model FieldsPagesRoutes
Annotating the modelAnnotating the model
Metadata on model controls behaviorDefault metadata inferred from schema
Data types and relationshipsRequired fields, field type, string length, etc.
Generate a Dynamic Data applicationAdd additional metadata
Validation Field labels and descriptionsPartial methods
DemoDemoASP.NET Dynamic Data
Field templatesField templates
Fields are rendered using templatesImplemented as a user control .ascxControls the rendering, data binding, and validationBased on the field data type, integer, bool, string, etc.Default selection can be overridden
Default field templates ‘out-of-the-box’These can be customized – they are just user controls
Create new field templates
Dynamic Data ControlsDynamic Data Controls
DynamicDataManagerGridView, DetailsView
DynamicDataField
ListView, FormViewDynamicControl
LinqDataSource, EntitiesDataSourceDynamicControlParameterDynamicQueryStringParameter
DynamicValidatorDynamicFilter, FilterRepeater
DemoDemoASP.NET Dynamic Data – Field Templates
.NET 3.5 SP1 – What’s been improved.NET 3.5 SP1 – What’s been improved
ASP.NET AJAXWCFWPFWinForms
Visual Studio 2008 SP1 – What’s else?Visual Studio 2008 SP1 – What’s else?
SQL 2008JavaScript formatting and code preferencesImproved JavaScript IntellisenseClassic ASP Intellisense/DebuggingWCF refactoring support (svc/config files).NET Framework Client Profile
26mb download