Performing part of a IQueryable query and deferring the rest to Linq for Objects

前端 未结 5 1042
温柔的废话
温柔的废话 2021-02-15 15:37

I have a Linq provider that sucessfully goes and gets data from my chosen datasource, but what I would like to do now that I have my filtered resultset, is allow Linq to Objects

5条回答
  •  花落未央
    2021-02-15 15:53

    Rob's answer is good, but forces full enumeration. You could cast to keep extension method syntax and lazy evaluation:

    var res = ((IEnumerable)dc.Foos
                .Where(x => x.Bla > 0))  // IQueryable
              .Where(y => y.Snag > 0)   // IEnumerable
    

提交回复
热议问题