What Should I know to underestand LINQ better?
As LINQ is a good query language in dot net and everyo开发者_JAVA技巧ne should be able to work with it. What are the necessary abilities which a programmer should have, before start learning LINQ.
And after that, What should he know about LINQ? (important tips)
What kind of Linq are you interested in - Linq to Objects, Linq to SQL, implementing your own Linq provider ?
My advice is that you should first learn about the features that Linq is based upon :
IQueryable and IEnumerable extension methods
Method chaining and deferred execution
Anonymous methods and lambda expressions
Linq query syntax
Expression trees (if you aim at implementing your Linq provider)
Then in turn these features rely on more basic concepts :
Generics
Delegates
Collections
A couple of books that could help you :
- C# in depth (J. Skeet) - great book to learn C#
- LINQ in Action (Marguerie, Eichert, Wooley)
A decent understanding of Closures / Lambda, IEnumerable, Generics, Expression Trees and Method Chaining, would be a good start. LINQ is pretty much just a utility set based upon that.
But you can definitely learn to utilize LINQ without a solid understanding of each and every single feature mentioned.
If you want to understand the principles behind LINQ than it is very useful to learn some basics of functional programming, because LINQ is largely based on this paradigm. Of course, you don't need that to use LINQ in practice, but it will help you understand what's going on under the cover (not to mention that learning functional programming is said to make you a better programmer anyway).
I wrote an overview article on this topic that you may find useful:
- Functional Programming using C# and F#
Aside from functional programming, it really helps to understand all C# 3.0 features, most importantly lambda expressions, extension methods and also expression trees. Technically speaking, LINQ is just a clever combination of these three features, so once you understnad them, you can fully appreciate and benefit from LINQ.
101 LINQ samples really helped me to understand LINQ better http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx?ppud=4
There is a series of videos (8, I believe) Scott Stanfield called "LINQ TO SQL." They are very helpful to understand the concept and how to use LINQ.
Link Here
Or, try google: LINQ TO SQL + Scott Stanfield
I particularly like to use, but little use. is always good care ... but it is very useful. Watch the videos and draws its conclusions.
Enjoy!
精彩评论