Introduction
In this blog we will see how LINQ query result can be converted into list and later how the list can be consumed according to the any requirement perspective.
Step 1: Create console application
Program.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace Convert_LINQ_Query_to_List
- {
- class Program
- {
-
- static void Main(string[] args)
- {
- SchoolManagementEntities objSchoolManagementEntities = new SchoolManagementEntities();
- var query = from r in objSchoolManagementEntities.Students select r;
- List<Student> lstStudents = query.ToList();
- }
- }
- }
Output of the application looks like this
Summary
In this blog we have seen how LINQ Query can be converted into list. Happy coding!