开发者

How to use Expression.IfThenElse in C#

I have a method in a repository:

Query<T>(System.L开发者_开发知识库inq.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!


Have you tried Expression.Condition

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜