asp.net 3.5 sp1

48
.NET 3.5 Enhancements (SP1) Dave Allen ISV Application Architect Developer and Platform Group Microsoft UK

Upload: dave-allen

Post on 19-May-2015

3.879 views

Category:

Technology


3 download

DESCRIPTION

ASP.NET 3.5 SP1

TRANSCRIPT

Page 1: ASP.NET 3.5 SP1

.NET 3.5 Enhancements (SP1)

.NET 3.5 Enhancements (SP1)Dave AllenISV Application ArchitectDeveloper and Platform GroupMicrosoft UK

Page 2: ASP.NET 3.5 SP1

AgendaAgenda

ADO.NET Entity FrameworkADO.NET Data ServicesASP.NET RoutingASP.NET Dynamic Data

Page 3: ASP.NET 3.5 SP1

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

Page 4: ASP.NET 3.5 SP1

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

Page 5: ASP.NET 3.5 SP1

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

Page 6: ASP.NET 3.5 SP1

DemoDemoEntity Data Model

Page 7: ASP.NET 3.5 SP1

Entity FrameworkEntity Framework

EDM consumption options:Entity Client

Entity SQLObject Services

Entity SQLLINQ To Entities

Page 8: ASP.NET 3.5 SP1

Entity ClientEntity Client

Familiar ADO.NET object model:EntityCommandEntityConnectionEntityDataReaderEntity ParameterEntityTransaction

Text-based resultsRead-onlyUses Entity SQL

Page 9: ASP.NET 3.5 SP1

Entity SQLEntity SQL

• SQL-like query language• Targets conceptual model• Database agnostic

T-SQL

Entity SQL

Page 10: ASP.NET 3.5 SP1

DemoDemoEntity Client

Page 11: ASP.NET 3.5 SP1

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

Page 12: ASP.NET 3.5 SP1

DemoDemoObject Services

Page 13: ASP.NET 3.5 SP1

Entity Framework – Service StackEntity Framework – Service Stack

LINQ To Entities

Object Services

Entity SQL

Entity Client

ADO.NET Provider

Page 14: ASP.NET 3.5 SP1

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

Page 15: ASP.NET 3.5 SP1

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

Page 16: ASP.NET 3.5 SP1

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

Page 17: ASP.NET 3.5 SP1

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

Page 18: ASP.NET 3.5 SP1

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

Page 19: ASP.NET 3.5 SP1

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)

Page 20: ASP.NET 3.5 SP1

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

Page 21: ASP.NET 3.5 SP1

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

Page 22: ASP.NET 3.5 SP1

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

Page 23: ASP.NET 3.5 SP1

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

Page 24: ASP.NET 3.5 SP1

DemoDemoADO.NET Data Services – Adventure Works

Page 25: ASP.NET 3.5 SP1

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

Page 26: ASP.NET 3.5 SP1

ClientsClients

Data Service

Page 27: ASP.NET 3.5 SP1

ASP.NET AJAX ClientASP.NET AJAX Client

DataServiceHTTP

DataModel

Sys.Data.DataService

JSON

ServerClient

Page 28: ASP.NET 3.5 SP1

ASP.NET AJAX ClientASP.NET AJAX Client

Sys.Data.ActionSequenceSys.Data.DataServiceSys.Data.QueryBuilder

Page 29: ASP.NET 3.5 SP1

.NET Client.NET Client

DataServiceHTTP

DataModel

DataServiceContext

ObjectModel

ServerClient

Page 30: ASP.NET 3.5 SP1

DemoDemoSilverlight 2.0 Client - Northwind

Page 31: ASP.NET 3.5 SP1

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

Page 32: ASP.NET 3.5 SP1

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

Page 33: ASP.NET 3.5 SP1

Operation BatchingOperation Batching

DataServiceContext

1) Get Entity #12) Get Entity #23) Get Entity #3

DataService

Operations:3 server hits

Without batching

GETGETGET

Page 34: ASP.NET 3.5 SP1

Operation BatchingOperation Batching

DataServiceContext

1) Get Entity #12) Get Entity #23) Get Entity #3

DataService

Operations:1 server hit

With batching

GET /$batch

Page 35: ASP.NET 3.5 SP1

DemoDemoOperation Batching

Page 36: ASP.NET 3.5 SP1

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)

Page 37: ASP.NET 3.5 SP1

DemoDemoASP.NET Routing

Page 38: ASP.NET 3.5 SP1

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

Page 39: ASP.NET 3.5 SP1

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

Page 40: ASP.NET 3.5 SP1

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

Page 41: ASP.NET 3.5 SP1

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

Page 42: ASP.NET 3.5 SP1

DemoDemoASP.NET Dynamic Data

Page 43: ASP.NET 3.5 SP1

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

Page 44: ASP.NET 3.5 SP1

Dynamic Data ControlsDynamic Data Controls

DynamicDataManagerGridView, DetailsView

DynamicDataField

ListView, FormViewDynamicControl

LinqDataSource, EntitiesDataSourceDynamicControlParameterDynamicQueryStringParameter

DynamicValidatorDynamicFilter, FilterRepeater

Page 45: ASP.NET 3.5 SP1

DemoDemoASP.NET Dynamic Data – Field Templates

Page 46: ASP.NET 3.5 SP1

.NET 3.5 SP1 – What’s been improved.NET 3.5 SP1 – What’s been improved

ASP.NET AJAXWCFWPFWinForms

Page 47: ASP.NET 3.5 SP1

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

Page 48: ASP.NET 3.5 SP1