Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
LINQ Refresher
          Owen Evans,
          Developer, Xero
          Blogger, http://bgeek.net




Thursday, February ...
LINQ




Thursday, February 19, 2009
Language INtegrated Query




Thursday, February 19, 2009
SELECT
          lets start at the beginning

Thursday, February 19, 2009
SELECT
               Structured Separated   LINQ
               Query Language (SQL)




Thursday, February 19, 2009
Back Up
          Anonymous Types

Thursday, February 19, 2009
Anonymous Types

               Allow you to create a new type without defining a class
                     two methods of...
Revisiting Select
         What does this give us?




Thursday, February 19, 2009
Answer?




           An IEnumerable<T>    Also See IQueriable<T>
                                          and
         ...
Order
          get in line

Thursday, February 19, 2009
Order By




Thursday, February 19, 2009
Join




Thursday, February 19, 2009
Let




Thursday, February 19, 2009
LINQ as Extension Methods




Thursday, February 19, 2009
Late Evaluation

               LINQ queries are not evaluated until you need the
               results (foreach, count, ...
Late eval can hide errors




Thursday, February 19, 2009
Things to remember about
          LINQ
               From Comes First (for intellisense purposes)
               can be ...
All in one place




Thursday, February 19, 2009
References

               MSDN: http://msdn.microsoft.com/en-us/library/
               bb308959.aspx
               LINQ...
A Few More References
          (thanks to Simon Green)

               http://www.linqpad.net/
               Great for l...
FIN




Thursday, February 19, 2009
Upcoming SlideShare
Loading in …5
×

Linq Refresher

997 views

Published on

Slides from the Wellington .net User Group on Wednesday 18th February 2009

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Linq Refresher

  1. 1. LINQ Refresher Owen Evans, Developer, Xero Blogger, http://bgeek.net Thursday, February 19, 2009
  2. 2. LINQ Thursday, February 19, 2009
  3. 3. Language INtegrated Query Thursday, February 19, 2009
  4. 4. SELECT lets start at the beginning Thursday, February 19, 2009
  5. 5. SELECT Structured Separated LINQ Query Language (SQL) Thursday, February 19, 2009
  6. 6. Back Up Anonymous Types Thursday, February 19, 2009
  7. 7. Anonymous Types Allow you to create a new type without defining a class two methods of declaration explicit new{ObjectName=object.Name} implicit new{object.Description} new{object.Name} is the same as new{Name=object.Name} Thursday, February 19, 2009
  8. 8. Revisiting Select What does this give us? Thursday, February 19, 2009
  9. 9. Answer? An IEnumerable<T> Also See IQueriable<T> and IOrderedEnumerable<T> Thursday, February 19, 2009
  10. 10. Order get in line Thursday, February 19, 2009
  11. 11. Order By Thursday, February 19, 2009
  12. 12. Join Thursday, February 19, 2009
  13. 13. Let Thursday, February 19, 2009
  14. 14. LINQ as Extension Methods Thursday, February 19, 2009
  15. 15. Late Evaluation LINQ queries are not evaluated until you need the results (foreach, count, etc.) Allows for optimisation and building up of the query over time Can produce unexpected results if you don’t know what to expect Thursday, February 19, 2009
  16. 16. Late eval can hide errors Thursday, February 19, 2009
  17. 17. Things to remember about LINQ From Comes First (for intellisense purposes) can be written using extension methods (helps in exploring what is possible) Can project to new lists of objects or anonymous objects Beware hard to follow LINQ Late Evaluation: things can change, beware holding onto the IEnumerable for too long. Thursday, February 19, 2009
  18. 18. All in one place Thursday, February 19, 2009
  19. 19. References MSDN: http://msdn.microsoft.com/en-us/library/ bb308959.aspx LINQ over REST (Astoria): http://msdn.microsoft.com/ en-us/library/bb308959.aspx Many many ORM’s now providing LINQ support: Lightspeed, NHibernate, LINQ to Entities (LINQ to SQL too but abandoned) Thursday, February 19, 2009
  20. 20. A Few More References (thanks to Simon Green) http://www.linqpad.net/ Great for learning LINQ, includes heaps of samples Works outside of Visual Studio See the generated SQL or lambda http://www.albahari.com/nutshell/linqbridge.aspx Use LINQ to Objects in projects targeting .NET 2.0 Thursday, February 19, 2009
  21. 21. FIN Thursday, February 19, 2009

×