LINQ<br />Samnang Cheng<br />MUM – 2011<br />http://samneang-ngeth.blogspot.com<br />
Agenda<br />What is LINQ?<br />Why LINQ?<br />LINQ with Object<br />LINQ with XML<br />LINQ with SQL<br />Demo<br />Q & A<...
What is LINQ?<br />Stands for Language INtegrated Query.<br />It is a Microsoft .NET Framework component that adds native ...
Why?<br />It provides consistent model for working with data across various kinds of data sources and formats, such as, Ob...
LINQ<br />
Operation Classification<br />
LINQto Object<br />The LINQ to Objects provider is used for querying in-memory collections, using the local query executio...
LINQto XML<br />The LINQ to XML provider converts an XML document to a collection of XElement objects, which are then quer...
LINQto SQL<br />The LINQ to SQL provider allows LINQ to be used to query SQL Server databases, including SQL Server Compac...
LINQto SQL<br />DEMO<br />The LINQ to SQL provider allows LINQ to be used to query SQL Server databases, including SQL Ser...
References<br />“LINQ Quickly“ - N Satheesh Kumar<br />“Pro LINQ in C# 2008” - Joseph C. Rattz, Jr.<br />http://en.wikiped...
Thank you!Q & A<br />Samnang Cheng<br />MUM – 2011<br />http://samneang-ngeth.blogspot.com<br />
Upcoming SlideShare
Loading in...5
×

Linq

3,330

Published on

LINQ to Object, LINQ to XML, LINQ to SQL

Published in: Education, Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,330
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Linq

  1. 1. LINQ<br />Samnang Cheng<br />MUM – 2011<br />http://samneang-ngeth.blogspot.com<br />
  2. 2. Agenda<br />What is LINQ?<br />Why LINQ?<br />LINQ with Object<br />LINQ with XML<br />LINQ with SQL<br />Demo<br />Q & A<br />
  3. 3. What is LINQ?<br />Stands for Language INtegrated Query.<br />It is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages.<br />It follows query expression rule.<br />
  4. 4. Why?<br />It provides consistent model for working with data across various kinds of data sources and formats, such as, Object, XML, Dataset, SQL, Entity with short and effective syntax.<br />Improve performance.<br />
  5. 5. LINQ<br />
  6. 6. Operation Classification<br />
  7. 7. LINQto Object<br />The LINQ to Objects provider is used for querying in-memory collections, using the local query execution engine of LINQ.<br />Example:<br />string[] greetings = { "Hello world", "Hello LINQ", "Hello Apress"};<br />var items = from s in greetings<br />where s.EndsWith("LINQ")<br />select s;<br />foreach (var item in items)<br />txtResult.Text += item + "n";<br />Result => Hello LINQ<br />
  8. 8. LINQto XML<br />The LINQ to XML provider converts an XML document to a collection of XElement objects, which are then queried against using the local execution engine that is provided as a part of the implementation of the standard query operator. <br />Example:<br />var titles = from book in books.Elements("book")<br /> where (string)book.Element("author") == "Steve Nolle"<br /> select book.Element("title");<br />foreach (var title in titles)<br />txtResult.Text = title.Value;<br />Result => Software Engineering<br />
  9. 9. LINQto SQL<br />The LINQ to SQL provider allows LINQ to be used to query SQL Server databases, including SQL Server Compact databases. <br />Example:<br />DataClasses1DataContext dc1 = new DataClasses1DataContext();<br />var hotel = from h in dc1.tbl_Hotels<br /> where h.city == "London"<br /> select h.hotelName;<br />foreach (string h in hotel)<br />txtResult.Text += h + "n";<br />
  10. 10. LINQto SQL<br />DEMO<br />The LINQ to SQL provider allows LINQ to be used to query SQL Server databases, including SQL Server Compact databases. <br />Example:<br />DataClasses1DataContext dc1 = new DataClasses1DataContext();<br />var hotel = from h in dc1.tbl_Hotels<br /> where h.city == "London"<br /> select h.hotelName;<br />foreach (string h in hotel)<br />txtResult.Text += h + "n";<br />
  11. 11. References<br />“LINQ Quickly“ - N Satheesh Kumar<br />“Pro LINQ in C# 2008” - Joseph C. Rattz, Jr.<br />http://en.wikipedia.org/wiki/Language_Integrated_Query<br />
  12. 12. Thank you!Q & A<br />Samnang Cheng<br />MUM – 2011<br />http://samneang-ngeth.blogspot.com<br />

×