2011-10-09 148 views
2

我很關心緩存EF結果,而且這是默認情況下。我有以下的庫:ASP.NET MVC&緩存EF

public class Model1Repository 
{ 
    private NEOGOV_IdeasEntities _dataContext; 
    public Model1Repository() 
    { 
     _dataContext = new NEOGOV_IdeasEntities(); 
    } 

    public List<Status> Statuses() 
    { 
     var query = from i in _dataContext.Statuses select i; 
     return query.ToList(); 
    } 
} 

與方法如下控制器:

public class TestController : Controller 
{ 
    private NEOGOV_Ideas.Models.Model1Repository _repository; 
    public TestController() 
    { 
     _repository = new NEOGOV_Ideas.Models.Model1Repository(); 
    } 

    public ActionResult Test1() 
    { 
     _repository.Statuses(); 
     _repository.Statuses(); 
     _repository.Statuses(); 
     _repository.Statuses(); 

     return View(); 
    } 
} 

我的理解中,以下狀態方法結果第一個電話後,應緩存,但我看到在SQL簡介:

exec sp_reset_connection 
go 
SELECT 
[Extent1].[StatusID] AS [StatusID], 
[Extent1].[StatusName] AS [StatusName] 
FROM [dbo].[Statuses] AS [Extent1] 
go 
exec sp_reset_connection 
go 
SELECT 
[Extent1].[StatusID] AS [StatusID], 
[Extent1].[StatusName] AS [StatusName] 
FROM [dbo].[Statuses] AS [Extent1] 
go 
exec sp_reset_connection 
go 
SELECT 
[Extent1].[StatusID] AS [StatusID], 
[Extent1].[StatusName] AS [StatusName] 
FROM [dbo].[Statuses] AS [Extent1] 
go 
exec sp_reset_connection 
go 
SELECT 
[Extent1].[StatusID] AS [StatusID], 
[Extent1].[StatusName] AS [StatusName] 
FROM [dbo].[Statuses] AS [Extent1] 
go 

有什麼不對?

回答