Given LINQ to Entities does not support “Custom methods” how do you stay DRY?

前端 未结 2 644
旧巷少年郎
旧巷少年郎 2020-12-17 21:08

I have run into this problem:

Custom Methods & Extension Methods cannot be translated into a store expression

Basically I have some complicated LINQ quer

2条回答
  •  庸人自扰
    2020-12-17 21:52

    EF can't compose a query out of a LINQ expression that includes a method. EF needs literal values to compose the SQL.

    You will have to make do with "common" queries that return a superset of the Entities you need for a given case, then use extension methods and LINQ to narrow down the return set once it has been returned from the database.

提交回复
热议问题