我发现了这个问题如何在 MVC 应用程序中缓存数据,我想知道是否能够将此方法与 IQueryable 数据一起使用。
Public Function GetUsers() As IQueryable(Of User) Implements IUserRepository.GetUsers
Dim users = (From u In dc.Users
Select u)
Return users.AsQueryable
End Function
我可以将其更改为
Public Function GetUsers() As IQueryable(Of User) Implements IUserRepository.GetUsers
Dim users = Cache("users")
If users Is Nothing Then
users = (From u In dc.Users
Select u)
Cache("users") = users
End If
Return users.AsQueryable
End Function