IQueryable vs IQueryable<T>

会有一股神秘感。 提交于 2019-11-29 14:44:23

The generic IQueryable<T> is the one you use most often in method signatures and the like. The non-generic IQueryable exist primarily to give you a weakly typed entry point primarily for dynamic query building scenarios.

by Matt Warren from LINQ: Building an IQueryable Provider - Part I

You should use generic IQueryable<T> everywhere it's possible.

neontapir

I imagine it's the same reason as Jon Skeet gives in Difference between IEnumerable and IEnumerable<T>? , to allow use in a foreach loop. IQuerable would be castable to IEnumerable, whereas IQueryable<T> would not.

Also see Marcin's answer about use in dynamic query building scenarios.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!