Should repositories implement IQueryable?

前端 未结 3 631
心在旅途
心在旅途 2020-12-08 07:41

I\'m considering one of two IRepository interfaces, one that is a descendant of IQueryable and one that contains IQueryable.

Like this:

public inter         


        
3条回答
  •  死守一世寂寞
    2020-12-08 08:09

    Depends on if you want a Has-A or an Is-A relationship.

    The first one is an Is-A relationship. The IRepository interface is a IQueryable interface. The second is a has-a. The IRepository has an IQueryable interface. In the process of writing this, I actually like the second better then the first, simply because when use your second IRepository, I can give the Query() method ANYTHING that returns IQueryable. To me, that is more flexible then the first implementation.

提交回复
热议问题