In which cases do I need to create two different extension methods for IEnumerable and IQueryable?

前端 未结 2 2211
隐瞒了意图╮
隐瞒了意图╮ 2021-02-19 14:25

Let\'s say I need an extension method which selects only required properties from different sources. The source could be the database or in-memory collection. So I have defined

2条回答
  •  深忆病人
    2021-02-19 15:20

    If your code only actually works when the objects its dealing with are loaded in memory, just supply the IEnumerable variant and let your callers decide when they want to convert an IQueryable into an in-memory IEnumerable.

    Generally, you won't implement new variations around IQueryable unless you're writing a new database provider.

提交回复
热议问题