Export (0) Print
Expand All

Convert a Sequence to a Generic List

Use ToList<TSource> to create a generic List from a sequence.

The following sample uses ToList<TSource> to immediately evaluate a query into a generic List<T>.

var empQuery =
    from emp in db.Employees
    where emp.HireDate >= new DateTime(1994, 1, 1)
    select emp;
    List<Employee> qList = empQuery.ToList();
Show:
© 2014 Microsoft