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
171,091 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
171,091 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.