ienumerable 存在于 system.collections 命名空间中。iqueryable 存在于 system 中。 linq 命名空间。ienumerable 和 iqueryable 都是正向集合。ienumerable 不支持延迟加载iqueryable 支持延迟加载从数据库查询数据时,ienumerable 在服务器端执行选择查询,在客户端将数据加载到内存中,然后过滤数据。从数据库查询数据,iqueryable 在服务器端执行选择查询带有所有过滤器的服务器端。ienumerable 扩展方法采用函数对象。iqueryable 扩展方法采用表达式对象意味着表达式树。示例ienumerabledbcontext dc = new dbcontext ();ienumerable<socialmedia>list = dc.socialmedias.where(p => p.name.startswith("t"));list = list.take<socialmedia>(1);</socialmedia>
为上述查询生成的sql语句select [t0].[id], [t0].[name] from [socialmedia] as [t0]where [t0].[name] like @p0
可查询dbcontext dc = new dbcontext ();iqueryable<socialmedia> list = dc.socialmedias.where(p => p.name.startswith("t"));list = list.take<socialmedia>(1);
为上述查询生成的sql语句select top 1 [t0].[id], [t0].[name] from [socialmedia] as [t0]where [t0].[name] like @p0
以上就是c# 中 ienumerable 和 iqueryable 有什么区别?的详细内容。