1 / 26

ADO vNext

ADO vNext. LINQ LINQ to SQL Entity Framework. Freek Leemhuis freek.leemhuis@logica.com. Microsoft en ORM – de historie. Microsoft en ORM – de historie. WinFS. Defining LINQ and LINQ to SQL. Bestaat uit taal uitbreidingen in C# 3.0 en VB 9.0

casta
Download Presentation

ADO vNext

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ADO vNext LINQ LINQ to SQL Entity Framework FreekLeemhuisfreek.leemhuis@logica.com

  2. Microsoft en ORM – de historie Microsoft en ORM – de historie WinFS

  3. Defining LINQ and LINQ to SQL • Bestaat uit taal uitbreidingen in C# 3.0 en VB 9.0 • Uniforme manier om queries uit te voeren op objecten LINQ LINQ to SQL • Een framework (OR mapper) voor het mappen van data classes op SQL Server tables, views en stored procedures.

  4. LINQ parts .Net APIs Providers Interne query engine LINQ to Datasets LINQ to SQL LINQ to XML LINQ to Entities LINQ to Objects IEnumerable IQueryable C# 3.0 VB 9.0 Others LINQ

  5. Taaluitbreidingen • Extension methods • Partial Methods • Lambda expressions • Anonymous types • Object initializers • Local variable inference • Linq keywords and operators

  6. Demo • Extention methods • Local variable inference • Anonymous types Demo

  7. De basis van LINQ • LINQ queries gaan over elementen uit sequences • Een sequence is een object dat de IEnumerable<T> interface implementeert Bijvoorbeeld: String[] namen = {“Maarten”, “Ralph”, “Freek”}; Selectie = namen.Where(n=>n.Contains(“a”)) .Orderby(n=>n) .Select(n=>n.ToUpper());

  8. IEnumerable

  9. Ienumerable : enumeratie met yield return

  10. Comprehension Syntax Demo

  11. Query voorbeelden Query composition var filtered = names .Where (n => n.Contains ("a")); var sorted = filtered.OrderBy (n => n); var query = sorted.Select (n => n.ToUpper( ));

  12. LINQ to XML • Demo

  13. Data Access met LINQ LINQ to SQL

  14. Object Relational Impedance Mismatch Objects != Data Relationele Data Objecten

  15. Verschillen tussen LINQ to SQL en het Entity Framework

  16. Data Access met ADO.Net Data Access met klassiekADO.Net Queries in quotes SqlConnection c = new SqlConnection(…); c.Open(); SqlCommandcmd = new SqlCommand( @"SELECT c.Name, c.Phone FROM Customers c WHERE c.City = @p0"); cmd.Parameters.AddWithValue("@p0", "London“); DataReaderdr = c.Execute(cmd); while (dr.Read()) { string name = dr.GetString(0); string phone = dr.GetString(1); DateTime date = dr.GetDateTime(2); } dr.Close(); Loosely bound arguments Loosely typed result sets No compile time checks

  17. Data Access met LINQ to SQL Classes describe data public class Customer { … } public class Northwind: DataContext { public Table<Customer> Customers; … } Tables are like collections Strongly typed connection Northwind db = new Northwind(…); var contacts = from c in db.Customers where c.City == "London" select new { c.Name, c.Phone }; Integrated query syntax Strongly typed results

  18. Linq to SQL : Mapping DB to Objects DataContext Database Table View Column Relationship Class + Collection Class + Collection Property Nested Collection Method Stored Procedure

  19. LINQ to SQLDataContext LINQ to SQL Architectuur from c in Context.Customers Where c.LastName.StartsWith(“Niks”) select new { c.Name, c.FirstName}; Customer c = new Customer();Customer.LastName = “Bos”;Customers.InsertOnSumbit(c);Context.SubmitChanges(); Services:- Change tracking- Concurrency control- Object identity select Name, FirstNamefrom customerswhere Lastname like ‘Niks%' Dynamische SQLof Stored Procedure Applicatie SQL Server

  20. LINQ to SQL Demo Title of Presentation

  21. Het ADO.Net Entity Framework Conceptual Mapping Logical CSDL MSL SSDL Object Model Relational Data Table Entity Table Entity Table Entity Table Entity Table

  22. Entity Relationship Model Dr. Peter Chen, 1970

  23. Entity Framework Architecture Object Services LINQ to Entities Object Query Entity SQL Entity SQL Entity Client Entity Framework Layers Conceptual CSDL Mapping MSL Logical SSDL

  24. Lange termijn visie op data access

  25. Resources Starten met Linq http://msdn2.microsoft.com/en-us/library/bb308961.aspx http://www.asp.net/learn/linq-videos/ http://weblogs.asp.net/scottgu/archive/tags/LINQ/ http://www.hookedonlinq.com/ http://msdn2.microsoft.com/en-us/vcsharp/aa336746.aspx Linqninjas http://blogs.msdn.com/mattwar/default.aspx http://weblogs.asp.net/fbouma http://codebetter.com/blogs/ian_cooper/ http://mtaulty.com LINQPad http://www.linqpad.net/

  26. Books

More Related