How I can call this LinqKit expression
public static Expression<Func<Transaction, string>> ExpressionOfStatusName
{
get
{
Expression<Func<Transaction, string>> status =
(transaction) => transaction.TransactionStatus.Name;
return status;
}
}
in a dynamic linq query (Linq as a string using System.Linq.Dynamic from Microsoft)
This expression works well in a standard Linq query like this
Expression<Func<Transaction, string>> expressionOfStatusName = Transaction.ExpressionOfStatusName;
var ex = from transaction in context.Transaction.AsExpandable()
select expressionOfStatusName.Invoke(transaction)
But when I try to call it from a dynamic linq query, I receive an error "No applicable method 'Invoke' exists in type 'Expression`1' I have tried to add the linqkit import in the file System.Linq.Dynamic but it is still not working.
I want to be able to do something like that
var ex = context.Transaction.AsExpandable()
.Select (transaction=>transaction)
.Select("new { test = expressionOfStatusName.Invoke(transaction)");
Thank you for your help