我一直在思考如何最好地缓存iqueryables。我正在使用存储库模式将数据提取到一个类中,例如:
public class Item
{
public int Id { get; set; }
public string Name { get; set; }
public IQueryable<Category> { get; set; } // For simplicity. It is actually a LazyList<Category> containing an IQueryable
}
现在,我该如何最好地缓存这个对象呢?我希望保留对查询的延迟执行,因为实际上除了类别之外,还有许多其他可以链接到项的东西,我最好不要将它们提取到对象上存储,因为对象可能会变得太大,或者它们可能需要单独缓存。
我在想一个
Compiled Query
我只是不太明白怎么可能。有人找到解决这个问题的好办法吗?这似乎是一种很常见的模式。