complex conditional where using lambda expression
Posted: Mon 03 May 2010 11:56
Hello guys,
I'm trying to write a query with a conditional where and i can't find a way to write it in the correct way.
The goal is:
A column named sectionID in the database is a String of values start with “;” and separated by ";".
A function called with a value of an int sectionID .
The where clause of the query should perform something like this:
If (sectionID > 0)
{
Query.Where(item=>item.SectionID.Contains(“;”+sectionID.ToString()+”;”));
}
is there any way to do it like this?
Thanks,
Eran.
I'm trying to write a query with a conditional where and i can't find a way to write it in the correct way.
The goal is:
A column named sectionID in the database is a String of values start with “;” and separated by ";".
A function called with a value of an int sectionID .
The where clause of the query should perform something like this:
If (sectionID > 0)
{
Query.Where(item=>item.SectionID.Contains(“;”+sectionID.ToString()+”;”));
}
is there any way to do it like this?
Thanks,
Eran.