What interface should my service return? IQueryable, IList, IEnumerable?

后端 未结 7 2291
孤独总比滥情好
孤独总比滥情好 2021-01-31 23:26

Imagine I have a SearchService layer that has a method to search all cars starting with a certain string;

public static class Searcher{
    public IAnInterface&l         


        
7条回答
  •  情深已故
    2021-01-31 23:35

    IQueryable would have a rather heavy requirement on it -- you couldn't, for example, return an array.

    Usually for me, the choice between IEnumerable or IList usually ends up being whichever is easier to implement in the standard case.

提交回复
热议问题