Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Lambda expression Tree loop

$
0
0

Hello,

Here is what i want to do:

List<String> values = new List<string>();
values.Add("value1");
values.Add("value2");
values.Add("value3");
values.Add("value4");
values.Add("value5");

Expression<Func<Contacts, bool>> expr1;
if (values.Count == 1)
{
expr1 = (x => x.fonction.Contains(values[0]));
}
else if (values.Count == 2)
{
expr1 = (x => x.fonction.Contains(values[0]) || x.fonction.Contains(values[1]));
}
else if (values.Count == 3)
{
expr1 = (x => x.fonction.Contains(values[0]) || x.fonction.Contains(values[1]) || x.fonction.Contains(values[2]));
}
...

I have tried everything, i did not managed to make it in a loop...


Can you help me ?

Thanks

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>