refactoring LINQ IQueryable expression to remove duplicated portions of queries

前端 未结 3 746
滥情空心
滥情空心 2021-02-09 11:40

I have some linq queries that have redundancy I\'d like to factor out a single piece of code. These are join experssions that are IQueryable, and its important I don\'t cause t

3条回答
  •  时光说笑
    2021-02-09 12:20

    We had the same problem. It is not supported out of the box and it is a major problem for LOB applications. I ended up writing a code-project article about LINQ expressions reuse, including a very small utility called LinqExpressionPrjection that enables the reuse in projections (including into anonymous types).

    Find the article here.

    You can get the assembly for the projection reuse as a nuget package and the source is on CodePlex.

    Some time has passed since your post. I hope it is still helpful for you. If not, maybe for others reading this thread.

提交回复
热议问题