12

Linq to SQL Chalk Talk Freek Leemhuis Rob Huibers Logica

Embed Size (px)

Citation preview

Page 1: Linq to SQL Chalk Talk Freek Leemhuis Rob Huibers Logica
Page 2: Linq to SQL Chalk Talk Freek Leemhuis Rob Huibers Logica

Linq to SQLChalk Talk

Freek LeemhuisRob HuibersLogica

Page 3: Linq to SQL Chalk Talk Freek Leemhuis Rob Huibers Logica

LINQ• Bestaat uit taal uitbreidingen in C# 3.0 en VB 9.0 • Uitbreidbaar door LINQ providers voor externe

data formaten (bijvoorbeeld MS SQL Server).

LINQ to SQL• Een framework(OR mapper) voor het mappen

van data classes op SQL Server tables, views en stored procedures.

Page 4: Linq to SQL Chalk Talk Freek Leemhuis Rob Huibers Logica

Taaluitbreidingen

• Linq keywords• Extension methods• Partial Methods• Lambda expressions• Anonymous types• Object initializers• Local variable inference

Page 5: Linq to SQL Chalk Talk Freek Leemhuis Rob Huibers Logica

LINQ parts

Interne query engine

LINQ to Objects

.Net APIs

LINQ to Datasets

LINQ to XML

Providers

LINQ to SQL LINQ to Entities

IQueryableIEnumerable

Page 6: Linq to SQL Chalk Talk Freek Leemhuis Rob Huibers Logica

Object Relational Mapping

Objecten

Objects != Data

Relationele Data

Page 7: Linq to SQL Chalk Talk Freek Leemhuis Rob Huibers Logica

LINQ to SQL Architectuur

from c in Context.Customers Where c.LastName. StartsWith(“Niks”)

select new { c.Name,

c.FirstName};

from c in Context.Customers Where c.LastName. StartsWith(“Niks”)

select new { c.Name,

c.FirstName};

select Name, FirstNameselect Name, FirstNamefrom customersfrom customerswhere Lastname like where Lastname like ‘Niks%'‘Niks%'

Services:Services:- Change tracking- Change tracking- Concurrency control- Concurrency control- Object identity- Object identity

Services:Services:- Change tracking- Change tracking- Concurrency control- Concurrency control- Object identity- Object identity

SQL Server

Customer c = new Customer();Customer c = new Customer();Customer.LastName = “Bos”;Customer.LastName = “Bos”;Customers.InsertOnSumbit(c);Customers.InsertOnSumbit(c);Context.SubmitChanges();Context.SubmitChanges();

Dynamische SQLDynamische SQLof Stored Procedureof Stored Procedure

Page 8: Linq to SQL Chalk Talk Freek Leemhuis Rob Huibers Logica

Het ADO.Net Entity FrameworkConceptual Mapping Logical

Object Model

Relational Data

Entity

Entity

Entity

Entity

Table

Table

Table

Table

CSDL MSL SSDL

Table

Page 9: Linq to SQL Chalk Talk Freek Leemhuis Rob Huibers Logica

LINQ to SQL versus Entity Framework

Page 10: Linq to SQL Chalk Talk Freek Leemhuis Rob Huibers Logica

Linq to SQL in N-tier Architectuur

Page 11: Linq to SQL Chalk Talk Freek Leemhuis Rob Huibers Logica

ResourcesStarten met Linqhttp://msdn2.microsoft.com/en-us/library/bb308961.aspxhttp://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.aspxLinq ninjashttp://blogs.msdn.com/mattwar/default.aspxhttp://weblogs.asp.net/fboumahttp://codebetter.com/blogs/ian_cooper/http://mtaulty.comLINQPadhttp://www.linqpad.net/

Page 12: Linq to SQL Chalk Talk Freek Leemhuis Rob Huibers Logica