Change the Rules Distributed data apps with .NET Zlatko Knezevic Developer Evangelist Microsoft zlatko.knezevic@microsoft.com Data options in .NET world 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 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 Visual Studio Entity Framework ADO.NET SQL Azure SQL Server “Quadrant” Data Services “M”/EDM SQL Server Modeling Services … Change the Rules ENTITY FRAMEWORK 4.0 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 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) Better Tools and Design Experience • • • • • • Model First Templated code generation Stored Procedures Pluralization/Singularization Complex Types Better delete and search More powerful/flexible runtime • • • • • • Deferred Loading (aka lazy loading) Foreign Keys surfaced More complete LINQ implementation ExecuteStoreQuery EntityFunctions and SqlFunctions Improvements to generated SQL Persistence Ignorance • First class support for Persistence Ignorance • No modifications to your classes! N-Tier • Self Tracking Entities 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 Change the Rules DEMO Change the Rules ODATA (WCF DATA SERVICES) oData? • What is it? • Why should we care? • How are we supposed to use it? 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 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?? REPRESENTATIONAL STATE REST TRANSFER 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 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 Data HTTP Source Options traffic Custom providers: - IDataServiceMetadataProvider - IDataServiceQueryProvider Data Services Runtime Updates: - IDataServiceUpdateProvider Entity Framework Provider Reflection Provider Entity Framework .NET Classes [+ LINQ provider] Database Data Source Custom Provider Data Source Special features: - IDataServiceStreamProvider - IDataServicePagingProvider Consume • Data on any platform • Bindings and POC code for – PHP – Java – JavaScript • Client libraries for .NET • Power Pivot and other means service interface business logic store 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 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 http://odata.org/producers 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 http://odata.org/consumers Clients • Excel + PowerPivot • LINQPad • OData Explorer Client libraries • .NET • Silverlight • Windows Phone 7 Series • Javascript • Java • Objective-C • PHP Change the Rules DEMO Change the Rules SQL SERVER 2008 R2 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… 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 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 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