Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Entity Framework Basics LINQ Queries Sorting Queries

What would the main purpose be to add LINQ queries to your program?

I imagine this would be useful by adding these queries to an application where it is attached to a submit button or search function. Other than that I don't see a point to add queries.

3 Answers

Steven Parker
Steven Parker
229,732 Points

LINQ can be very handy for all sorts of operations with arrays or lists. It makes it easy to do things like filtering, sorting, grouping, all simultaneously and in various combinations.

You're probably just seeing a specific aspect of it in this EF course, but there's another one that focuses on it directly called Querying With LINQ that you might enjoy.

Ah yes that course uses the command line and csharp which isn't useful if you are new and trying to visualize the complete code. I was frustrated with that course and broke off to this one which is a lot better by actually using Visual Studio and I can attest that I learned better about LINQ in this course.

So speaking of other aspects to use LINQ, you could use a query in LINQ to return a filtered list in a function?

Steven Parker
Steven Parker
229,732 Points

Sure, that would be a typical use of LINQ.

For example you can show a list of specific items in your ASP program using a database. Let's suppose you have a database table called students and it has studentID, first_name, last_name, age. You can show or return a list of items(students) in ur ASP program. Instead of typing"SELECT * FROM students" use LINQ queries.