Linq view part1


Published on

The first part of a series of workshops about linq.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Linq view part1

  1. 1. Microsoft LinqInsightspart 1<br />A tech overview <br />Alexandre Marreiros, 2011<br />
  2. 2. Agenda<br />Alexandre Marreiros, 2011<br />Using LINQ<br />References<br />Contacts<br />Pre-Requirements<br />Introduction<br />LINQ Principles<br />Query<br />
  3. 3. Introduction<br />Alexandre Marreiros, 2011<br />Linq acronym for: Language Integrated Query<br />It extends .NET to access Data in a easy and integrated way to CLI Languages.<br /> Almost anything can be a DataSource to Linq.<br />Data Sources<br />Linq<br />.Net Framework<br /> WPF<br />WCF<br /> WWF<br /> WPF<br />.Net Framework<br />
  4. 4. Introduction<br />LINQ extends CLI languages with the power to querying data, directly. <br />Avaiable to and C#.<br />.NET Standard to query multiple data sources.<br />Declarative style of programming.<br />Support for multithread programming.<br />Alexandre Marreiros, 2011<br />
  5. 5. Introduction<br />Alexandre Marreiros, 2011<br />
  6. 6. Demo<br />Alexandre Marreiros, 2011<br />Presenting Query expression, LINQ to Object and LINQ to SQL<br />
  7. 7. LINQ Principles <br />Alexandre Marreiros, 2011<br />LINQ key Ideas are:<br />Integrated;<br />Declarative;<br />Unitive;<br />Extendable;<br />Hierarchical;<br />Composable;<br />
  8. 8. LINQ Principles <br />Alexandre Marreiros, 2011<br />Integrated<br />One of the main goals of LINQ is to integrate a flexible query sintax in to .NET languages. <br />Querying data in .net can be confused and tricky theres an example:<br />SqlConnection connection = new SqlConnection(connectionString);<br />connection.Open();<br />System.Data.SqlClient.SqlCommand sqlCommand = new SqlCommand();<br />sqlCommand.Connection = connection;<br />sqlCommand.CommandText = "Select * from Customer";<br />sqlCommand.ExecuteReader(CommandBehavior.CloseConnection);<br />
  9. 9. LINQ Principles <br />Alexandre Marreiros, 2011<br />Integrated<br />LINQ offers a mutch more integrated mode and code cust effective.<br />Querying in LINQ:<br />Contacts DB = new Contacts(@c:Contacts.mdf);<br />var query = from contact in DB.Contacts;<br /> select c;<br />
  10. 10. LINQ Principles <br />Alexandre Marreiros, 2011<br />Unitive<br />Without LINQ a data driven programs will have in the same code a mix off different technologies<br />Just LINQ<br />Just #<br />SQL<br />C#<br />And, OR<br />XML<br />Parsing<br />C#<br />
  11. 11. LINQ Principles <br />Alexandre Marreiros, 2011<br />Extendable<br />LINQ is a technologie based in providers.<br />You Can extend LINQ Implementing new Providers. <br />All providers are adressed with the same syntax.<br />
  12. 12. LINQ Principles <br />Alexandre Marreiros, 2011<br />Declarative<br />varqueryNames = from realNamein names <br /> where realName != "" <br /> select realName;<br />Focus in What You Want<br />Not In How you do <br />
  13. 13. LINQ Principles <br />Alexandre Marreiros, 2011<br />Hierarchical<br />
  14. 14. LINQ Principles <br />Alexandre Marreiros, 2011<br />Composable<br />Query can be composed from other queties<br />
  15. 15. Demo<br />Alexandre Marreiros, 2011<br />A FewqueryExamplesmadefromtheroots<br />
  16. 16. Using Linq<br />Use Linq to easy query datasources as databases, object collections, XML, Excel Files and others.<br />Extend Linq to support aditional datasources.<br />In database or business service Layers use Linq to reduce Complexity.<br />Don´t throw away ADO.NET in data relational database think if he can be a best Aproach.<br />Alexandre Marreiros, 2011<br />
  17. 17. Commingnext<br />NowthatwealreadyunderstandWhat´s LINQ inthenextpartwewillseehow to use thedifferent LINQ model’s.<br />(LINQ to SQL, LINQ to XML, LINQ to Object,How to extend LINQ, LINQ to Sharepoint)<br />Alexandre Marreiros, 2011<br />
  18. 18. Alexandre Marreiros, 2011<br />References <br />Http://Linq in Action – Fabrice MargueirePro Linq Language integrated query 2010 in c# 2010 – Joseph C. RattzProgramming Microsoft ASP.NET 3.5 – Dino Esposito<br />
  19. 19. Contacts<br />Alexandre Marreiros, 2011<br />Email:<br />Twitter: @alexmarreiros<br />Feel free to ask<br />