Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft...

37
Change the Rules Distributed data apps with .NET Zlatko Knezevic Developer Evangelist Microsoft [email protected]

Transcript of Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft...

Page 1: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Change the Rules

Distributed data apps with .NET

Zlatko KnezevicDeveloper Evangelist

[email protected]

Page 2: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Data options in .NET world

Page 3: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Some history included

• Native interfaces• ODBC as a abstraction layer• OLE DB• ADO.NET as a wrapper with .NET–With factories in 2.0 world

• ORMs as of 3.0

Page 4: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Today, things are different

• Client-server is a past paradigm

• Services talking to one another

• Distribution of data, applications, infrastructure

• TDD/DDD/BDD as a development practice

Page 5: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

SQLServer

SQLAzure

Visual Studio “Quadrant”

SQL Server Modeling Services

Entity Framework

ADO.NET “M”/EDM

Data Services

Page 6: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Change the Rules

ENTITY FRAMEWORK 4.0

Page 7: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Entity Framework 1.0 had too many pain points

• The designer!• Model First not supported• Poor support for Stored Procedures• No Pluralization/Singularization• Foreign Keys hidden• Lazy Loading not supported• Missing LINQ Operators vs LINQ to SQL• Generated SQL unreadable• No support for Plain Old CLR Objects• N-Tier difficult

Page 8: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

New in Entity Framework 4• Model-first development• Automatic pluralization• Foreign keys in models• POCO class support (Add-in)• Lazy loading• T4 Code Generation• Template customization• IObjectSet• Virtual SaveChanges• ObjectStateManager control

• Self-tracking entities• SQL generation

improvements• More LINQ operator

support• LINQ extensibility• ExecuteStoreQuery• ExecuteStoreCommand• SPROC import

improvements• Model defined functions• WPF designer integration• Code-First development

(Feature CTP)

Page 9: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Better Tools and Design Experience

• Model First• Templated code generation• Stored Procedures• Pluralization/Singularization • Complex Types• Better delete and search

Page 10: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

More powerful/flexible runtime

• Deferred Loading (aka lazy loading)• Foreign Keys surfaced• More complete LINQ implementation• ExecuteStoreQuery• EntityFunctions and SqlFunctions• Improvements to generated SQL

Page 11: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Persistence Ignorance

• First class support for Persistence Ignorance

• No modifications to your classes!

Page 12: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

N-Tier

• Self Tracking Entities

Page 13: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Code Only database modelling

• All above is nice, but you still need the edmx file

• What if you want the code to be “the truth”?

• Code-only modelling means just that• Currently only in CTP

Page 14: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Change the Rules

DEMO

Page 15: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Change the Rules

ODATA (WCF DATA SERVICES)

Page 16: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

oData?

• What is it?

• Why should we care?

• How are we supposed to use it?

Page 17: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

A little bit of history…

• MIX07 was a birthplace of “Astoria”• Later renamed ADO.NET Data

Services• Requirements for web data services– Plain HTTP– Uniform patterns– Focus on data– Abstract

Page 18: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Basic idea

The basic idea is simple

You already have this HUGE platform and API thing

Why not build on top of it??

In a way that is friendly and automatic??

Page 19: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

RESTREPRESENTATIONAL

STATETRANSFER

Page 20: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

| !protocol| !standard| !format

REST

Page 21: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

REST == architectural style

Page 22: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

| decoupling| scalability| layering

REST

Page 23: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

OData

• Uniform way of representing structured data– Atom, JSON formats

• Uniform URL conventions– Navigation, filtering, sorting, paging, etc.

• Uniform operations– Addressability– GET, POST, PUT, DELETE always mean the same

Page 24: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Expose

• Any data over HTTP• Through either JSON or XML (Atom)• Your source needs to be

IQueryable<T>• Works like a charm for Entity

Framework contexts

Page 25: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Data Source Options

Data Services Runtime

HTTP traffic

Entity Framework Provider

Reflection Provider Custom Provider

.NET Classes[+ LINQ provider]Entity Framework

Database Data Source

Data Source

Custom providers:- IDataServiceMetadataProvider- IDataServiceQueryProvider

Updates:- IDataServiceUpdateProvider

Special features:- IDataServiceStreamProvider- IDataServicePagingProvider

Page 26: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Consume

• Data on any platform• Bindings and POC code for– PHP– Java– JavaScript

• Client libraries for .NET• Power Pivot and other means

Page 27: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

got an HTTP stack?

Page 28: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

business logic

store

service interface

data service != gateway to database

Page 29: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

oData point: SharePoint 2010

• SharePoint needed 2 things in this space

• Flexible data interface–Maximize reach, minimum barrier of entry– Data centric, but enforcing business logic

• Developer story– Libraries for as many clients as possible– Great Visual Studio integration

Page 30: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

oData consumer: PowerPivot

• “Self-service business intelligence”– Let people find and use their own data– …but where’s the data?

• Broad direct database access is impractical– OData feeds expose data over application logic– PowerPivot can handle OData natively

• Reports often represent the best data sources– All reports in Reporting Services are now OData

feeds

Page 31: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Servers• WCF Data Services• SharePoint 2010• SQL Server Reporting Services 2008 R2• SQL Azure• IBM WebSphere eXtreme Scale• Microsoft Media Room• WCF RIA Services

Services• Netflix• Mix 2010• Nerd Dinner• Vancouver’s vanGuide• Open Government Data Initiative• Open Science Data Initiative• Microsoft Codename “Dallas”• City of Edmonton

Clients• Excel + PowerPivot• LINQPad• OData Explorer

Client libraries• .NET• Silverlight• Windows Phone 7 Series• Javascript• Java• Objective-C• PHP

http://odata.org/producers

http://odata.org/consumers

Page 32: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Change the Rules

DEMO

Page 33: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Change the Rules

SQL SERVER 2008 R2

Page 34: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

SQL Server 2008 at a glance

• A lot of improvements for next-generation apps• Beyond rational data types

– Spatial Data type– Hierarchy data type

• Improvements in rational engine– FILESTREAM data type– New DateTime functions

• Support for sparse columns• Better management• And a lot more…

Page 35: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

SQL Server 2008 R2

• Adding on the solid foundation that is SQL 2008

• Improvements in management, reporting and federation

• StreamInsight™ • Support for oData in Reporting Services• Better business insight with new BI

advances– PowerPivot

Page 36: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Visual Studio 2010 & SQL Server 2008 R2

• Continued “DB professional” support– Offline database projects– Provides a place for the DB in ALM cycle

• New T-SQL IDE and developing features

• Data-tier Application projects

Page 37: Change the Rules Distributed data apps with.NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com.

Data-tier Applications

• Improved Transact-SQL IDE• Supports offline development,

refactoring, versioning, policy• Builds single unit of deployment

containing all database objects (DACPAC)

• Registered with SQL Server when deployed