How can I learn LINQ?

MitjaHd

New member
Joined
Jun 23, 2019
Messages
3
Programming Experience
Beginner
I'm a begginer and started doing some coding on codewars, website where you code simple algorithms. And I found out I don't really have good understand of core C# concepts, I saw I could do a lot of stuff using LINQ instead of for and foreach statements. I'm struggling with learning LINQ, I read some tutorials and watch some youtube videos, but it seems too hard to me, perhaps I lack enough exerience in other concepts like OOP (which I understand, but not completely). What should I know before learning LINQ and what is a good palce to learn it? Thanks.
 
Or alternatively, another way to learn how to use the extension methods that LINQ ends up being converted to by the compiker, immerse yourself into functional programming, and the functional way of thinking.
 
Alright will look deeper into SQL, I already know few commands and can use it with PHP to add and get stuff from database, etc. Then slowly going into LINQ, I got really confused when I saw lambda (=>).
 
Are you actually using LINQ query syntax?
C#:
var highScores = from student in students
                 where student.ExamScores[exam] > score
                 select new {Name = student.FirstName, Score = student.ExamScores[exam]};

Or are you using the method syntax?
C#:
var highScores = students.Where(student => student.ExamScores[exam] > score)
                          .Select(student => new { Name = student.FirstName, Score = student.ExamScores[exam] });

If you are using the former, then yes, understanding SQL with help you a lot. If you are using the latter, then functional programming may help more.

(See Query Syntax and Method Syntax in LINQ)
 
Back
Top Bottom