Udostępnij za pośrednictwem


How to: Convert a Sequence to a Generic List (LINQ to SQL)

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

Example

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

Dim empQuery = _
    From emp In db.Employees _
    Where emp.HireDate.Value >= #1/1/1994# _
    Select emp
Dim qList As List(Of Employee) = empQuery.ToList()
var empQuery =
    from emp in db.Employees
    where emp.HireDate >= new DateTime(1994, 1, 1)
    select emp;
    List<Employee> qList = empQuery.ToList();

See Also

Other Resources

Query Examples (LINQ to SQL)