Reputation: 1127
I have a method in a repository:
Query<T>(System.Linq.Expressions.Expression<Func<T,bool>> function)
When i call it, I want to use different Expressions based on a condition.
I tried:
m_Repository.Query<MyObject>(x => x.Infos.Count > 1 ?
x.Infos.Any(y => y.Info.Name.StartsWith(s)) :
x.Name.StartsWith(s));
but then it always executes the else part. I figured I had to use Expression.IfThenElse, but I cannot make it work. Any suggestions on how to do this?
Thanks!
Upvotes: 2
Views: 2196