Actually if it is final projection, you don't have to translate this function.
If not, you have to use third party extensions for that:
https://github.com/hazzik/DelegateDecompiler
https://github.com/axelheer/nein-linq/
Never tried DelegateDecompiler
, so will show sample using NeinLinq
[InjectLambda]
public double GetDebitOuCredit(string choix, string dcMoins, double? montantDebit, double? montantCredit)
{
_getDebitOuCreditFunc ??= GetDebitOuCredit().Compile();
return _getDebitOuCreditFunc(choix, dcMoins, montantDebit, montantCredit);
}
static Func<string, string, double?, double?, double> _getDebitOuCreditFunc;
public static Expression<Func<string, string, double?, double?, double>> GetDebitOuCredit()
{
return (choix, dcMoins, montantDebit, montantCredit) =>
montantDebit != null && montantDebit != 0 && montantCredit != null && montantCredit != 0)
? ((double)montantDebit < (double)montantCredit) && dcMoins == "1"
? choix == "Debit" ? 0 : (double)montantCredit) - (double)montantDebit
: choix == "Debit" ? (double)montantDebit - (double)montantCredit) : 0
: 0;
}
Then you can use your function in LINQ queries after ToInjectable()
call.
result = from ecriture in db.Ecrits.ToInjectable()
join compte in db.Comptes on ecriture.Compte equals compte.Compte1
...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…