问题描述
大家好请各位帮我了解一下asp.net mvc5,e.f 6默认使用 IQueryable 或 IEnumrable ?我想使用 IQueryable 工作,因为它最适合底层数据库。我正在使用LINQ to entity方法和var关键字来保存linq结果。默认情况下,我的模型类的类型为 public< dbset> className {get;设置}
所以这里< DbSet>
返回 IQueryable 或 IEnumrable ?
请帮助我
我尝试过:
我试过谷歌但仍未找到
Hi everyone please help me to understand about asp.net mvc5 with e.f 6 is used IQueryable or IEnumrable by default? I want to work using IQueryable because it is best for underlying database. I am using LINQ to entity approach and var keyword for holding linq results. By default my model classes is of type public <dbset> className {get; set}
so here <DbSet>
returns IQueryable or IEnumrable?
kindly help me
What I have tried:
I have tried google but still not find
推荐答案
using (var context = new ProductContext())
{
// This does not execute the query, but rather just configures it.
// The result is very much like IQueryable.
var query = context.Where(e => [Something]).OrderBy(e => [Something]);
// Once you force enumeration of the query you get an IEnumerable back.
// It is enumerated by a foreach, ToArray, ToDictionary, ToList, or any
// linq operator such as First or Any
IEnumerable<product> results = query.ToList();
}
这篇关于Iqueryable或可忍受?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!