Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ronnie Saurenmann Principal Architect Microsoft Switzerland.

Similar presentations


Presentation on theme: "Ronnie Saurenmann Principal Architect Microsoft Switzerland."— Presentation transcript:

1 Ronnie Saurenmann Principal Architect Microsoft Switzerland

2 Objects XML.NET Language Integrated Query C# 3.0VB 9.0Others… Relational LINQ to Objects LINQ to SQL LINQ to XML LINQ to Entities LINQ to DataSets

3 Application SQL Server LINQ to SQL from c in db.Customers where c.City == "London" select c.CompanyName LINQ Query SQL Query SELECT CompanyName FROM Cust WHERE City = 'London' Rows ObjectsSubmitChanges() DML or SProcs db.Customers.Add(c1); c2.City = "Barcelona"; db.Customers.Remove(c3); INSERT INTO Cust … UPDATE Cust … DELETE FROM Cust …

4

5 DataContext Strongly typed database connection Designer Relationships One-to-one, one-to-many Inheritance Custom types Intellisense and compiler validation “Strongly typed query” Super easy to write query

6

7 Relationships Pre-defined joins No need to declare the join in the query Ad hoc joins Inner joins and grouped joins Hierarchical navigation

8

9 Stored procedures support For Reads For Inserts, Updates and Deletes Custom SQL Queries DataContext1.Execute…. Custom Types Instead of anonymous types (var) Can use the designer or your own class

10

11 Change tracking Updates through dynamic SQL DML or stored procedures Ugly: no client side change tracking Optimistic concurrency Using version numbers, time stamps, or previous values Tip: use timestamps when possible Deep save with foreign key order Customers  Orders

12

13 Property change notification OnLimitChanging(decimal value) Ugly: watch out deserialization!.SubmitChange notification OnValidate(System.Data.Linq.ChangeAction action) DataContex UpdateCreditCardLimit(CreditCardLimit instance) SubmitChanges(System.Data.Linq.ConflictMod e failureMode)

14

15 Optimized with new row_count feature in SQL Server 2005 Page 1 or Page 10000 same speed Query stops as soon as it has the right page size (e.g 10 rows) Only the page size (e.g. 10 rows ) is transferred from the DB Falls back to a simpler version on SQL 2000 ASP.NET LinqDataSource Control Automatically done Custom made with “skip()” and “take()”

16

17

18 Change tracking in stateless environment ASP.NET Understand when query are executed and how Lazy vs. Eager Loading

19 DataContext is in charge for the Change Tracking DataContext is not serializable It cannot be put on Session state (anyway it would be bad) Change tracking should be stateless Manually store in ViewState original values or better timestamp LinqDataSource does it automatically Stores original values in ViewState

20 Page1 instance DataContex instance DataContex instance Response Submit Browser Request Page1 new instance New DataContex instance New DataContex instance Changes to the “Customer” object done on the 2 nd request Need to send back original and new values Changes to the “Customer” object done on the 2 nd request Need to send back original and new values

21

22 Lazy vs. Eager Loading Ugly: Eager loading at DataContext only affects all queries! Understanding when query are executed Query composition In memory query Good: for caching scenario

23

24

25 No disconnected client side change tracking! For the moment need to build your own Real drawback for multi tier architecture

26 Service instance DataContex instance DataContex instance Response SaveData WPF / WinForm / Silverlight GetData Service new instance New DataContex instance New DataContex instance Response Changes done on the client “Customer” object Need to manually send back original values Changes done on the client “Customer” object Need to manually send back original values

27

28 Works only with SQL Server Very hard to write a provider Competition from ADO.NET Entity Framework Will have other providers like Oracle Will not have multi tier change tracking support neither Shipping 2H 2008

29 The Good Easy to use Very powerful for read operations Absolutely recommended for 2-tier app Good for most ASP.NET architectures Where Data Access Layer and Presentation Layer are in the same process Released

30 The Bad The Challenging Change tracking in stateless environment (ASP.NET) Understand when query are executed and how Lazy vs. Eager Loading The Ugly Doesn't have multi tier change tracking support ADO.NET Entity Framework is an alternative Works only with SQL Server

31 Use the SQL Profiler all the time!!

32 © 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.


Download ppt "Ronnie Saurenmann Principal Architect Microsoft Switzerland."

Similar presentations


Ads by Google