I have one expression , for example x=>x.Id
;
And I have a function, where I need to combine two expressions. I use Linqkit .
My model:
public class Model{
Expression<Func<Entity,bool>> Expr {get;set;}
}
public Model Combine(Model input)
{
var exp = x => input.Expr.Invoke(x) && x.Name.Contains("A");
input.Expr = exp;
input.Expr.Compile();
return input;
}
Than I want to pass it in my repository, where I need to sort my entity.
public Ienumerable<Entity> Get(Model model)
{
var entity = _context.Entity.Where(model.Expr).ToList(); // there A cycle was detected in a LINQ expression exception
}