Entity Framework 6 - Extension Methods for DbFunctions

c# entity-framework entity-framework-6

Accepted Answer

ZZZ_tmp
1
7/24/2015 5:37:26 PM

Popular Answer

In this instance, Entity Framework 6 is foolish. It just tries to connect[DbFunction] property from the procedure and substitutes it withDbExpression using System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.Translator 13 through Z class. Consequently, there is no possibility to register a custom translation created from external code. Additionally,.NET does not provide the dynamic attachment of properties to language constructs.

You can choose from the following options to resolve this problem:

  • substitute methods with calls to the equivalentDbFunctions code in the source (SSR ReSharper works well for this);
  • implement ExpressionVisitor (and perhapsIQueryProvider ) which will substitute methods of (instead of method calls)DbFunctions class.
  • implement ExpressionVisitor (and perhapsIQueryProvider ) that converts method call expressions toDbFunctionExpression .


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow