1.NET Language Integrated Query Yishai Zaltzberg
2 Agenda: Why LINQ? What is LINQ Code samples Compare to code without LINQ Simple query Working with Xml Aggregation Join Use SP Etc. Impact and performance. Questions ?
3 Classic ADO.NET SqlConnection conn = new SqlConnection(“...“); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText SELECT * FROM Vehicles WHERE Model “Mercedes“); SqlDataReader r = cmd.ExecuteReader(); while ( r.HasRows ) { Console.WriteLine(r[“Number"] + r[“Year"]); } SqlConnection conn = new SqlConnection(“...“); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText SELECT * FROM Vehicles WHERE Model “Mercedes“); SqlDataReader r = cmd.ExecuteReader(); while ( r.HasRows ) { Console.WriteLine(r[“Number"] + r[“Year"]); } Application Relational Database No intellisence No compile time checks Untyped Results
4 XML Objects Relational Data
5 Samples
6 Simple Xml Build – Before LINQ
7 Simple Xml Build
8 Before LINQ
9 Build Xml from DB