【发布时间】:2013-07-09 23:21:51
【问题描述】:
我在 asp.net mvc web 应用程序中使用实体框架。我有以下查询:-
public AccountDefinition GetCustomer2(int id){
var c = entities.AccountDefinitions.Where(s=>s.ORG_ID==id)
.Include(a=>a.SDOrganization)
.Include(a1=>a1.SiteDefinitions);
var c2 = c.Select(a=>a.SDOrganization); //code goes here }
从以下动作方法中调用:-
public ActionResult Index(int searchTerm)
{ var accountdefinition = repository.GetCustomer2(searchTerm).ToList();
return View(accountdefinition);
}
所以当我创建 c2 var 时,它会查询数据库还是数据将在第一次调用时存储在内存中,当到达 .Tolist() 时?
第二个问题,如果我在创建Var c时将.Include替换为.Select,会不会有同样的效果?
【问题讨论】:
标签: entity-framework