Expose a repository as an IQueryable

前端 未结 5 1925
梦如初夏
梦如初夏 2021-01-21 20:58

I\'d like to expose a Repository as an \'IQueryable\' type.

The repository uses Linq to NHibernate to communicate with the database.

Can anyone point me at an ex

5条回答
  •  庸人自扰
    2021-01-21 21:33

    This is a bad design.

    An IQueryable is a question (lookup "query" in a dictionary). It's how you ask for data. It's what you should be giving to the Repository.

    A Repository should be returning answers -- the data itself.

    If the Repository is returning a IQueryable, you've pretty much negated the need for the Repository.

提交回复
热议问题