Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linq 是否允许存储库与服务层返回视图或视图模型?哪些应该被缓存?_Linq_Azure_Repository_Repository Pattern_Odata - Fatal编程技术网

Linq 是否允许存储库与服务层返回视图或视图模型?哪些应该被缓存?

Linq 是否允许存储库与服务层返回视图或视图模型?哪些应该被缓存?,linq,azure,repository,repository-pattern,odata,Linq,Azure,Repository,Repository Pattern,Odata,我正在使用Azure AppFabric与一个全新的存储库进行缓存。我的存储库如下所示: public interface IMyRepository { public IEnumerable<K> Select(IQueryable<T> someQuery) public IEnumerable<T> SelectAllStudents() // should I replace T with Children in my repository

我正在使用Azure AppFabric与一个全新的存储库进行缓存。我的存储库如下所示:

public interface IMyRepository
{
  public IEnumerable<K> Select(IQueryable<T> someQuery) 
  public IEnumerable<T> SelectAllStudents()  // should I replace T with Children in my repository?
}
公共接口IMyRepository
{
公共IEnumerable选择(IQueryable someQuery)
public IEnumerable SelectAllStudents()//我应该在存储库中将T替换为子级吗?
}
我的目的是公开和缓存来自客户机的OData请求,因此是IQueryable。我还有一个次要的需求,就是经常返回类似这样的数据

public class Children
{
  public string Name {get;set;}

  public int CountOfToys {get;set;}

  public List<Toys> {get;set;}
}
公共类子类
{
公共字符串名称{get;set;}
公共int CountOfToys{get;set;}
公共列表{get;set;}
}
然而,我的数据库是一个
1

当前的ASP.NET应用程序直接在aspx页面中使用EF的导航属性来填充上面的ViewModel,但是我不知道将此功能路由到存储库的最有效方法

由于AppFabric缓存,我对IEnumerable结果的限制如下:

  • 返回的对象不能是值类型
  • 返回的对象必须是可序列化的
  • 如何实现IMyRepository以支持缓存OData查询
  • 存储库不仅可以发出模型类,还可以发出“子”聚合类,这样可以吗?这个词的正确名称是什么
  • 假设上面的步骤没有问题,我应该使用导航属性来填充这个额外的类吗

  • 缓存存储库实体将更容易控制,这意味着您的系统中有一个内存中的数据库,但性能和灵活性较差。缓存域对象可以提供更高的性能,因为它更接近您实际想要缓存的对象。但是您需要考虑缓存项之间的同步。我想通过引入一个独立的缓存管理器组件,在服务层上进行缓存。

    让我觉得应该让存储库保持IQueryable,然后缓存服务层。思想?