What's the return type of a LINQ query?

后端 未结 5 602
轻奢々
轻奢々 2021-02-11 22:20

Is it IEnumerable. As far as I know, the reference always points to a class instance. What instance type does the LINQ query really point to?

5条回答
  •  悲哀的现实
    2021-02-11 23:03

    Depending on your original data source, it is either IEnumerable or IQueryable:

    The result of a Linq database query is typically IQueryable which is derived from IEnumerable, IQueryable, and IEnumerable.

    If your database query includes an OrderBy clause, the type is IOrderedQueryable, being derived from IQueryable

    If your data source is an IEnumerable, the result type is IEnumerable

提交回复
热议问题