I use EntityFramework with POCOs.
Suppose I have POCOs defined like this (simplified):
class Class1
{
public int ID;
public int SomeNumber;
}
class
According to your logic, if x.Class1 is not null, but x.Class1.SomeNumber is 3, it won't check all the other clauses.
If you want to check, if just some ClassN.SomeNumber == SomeNumber
, then you should do it like this:
int SomeNumber = 1; // some number
List retValue = result
.Where(x =>
{
if (x.Class1 != null && x.Class1.SomeNumber == SomeNumber)
return true;
else if (x.Class2 != null && x.Class2.SomeNumber == SomeNumber)
return true;
else if (x.Class3 != null && x.Class3.SomeNumber == SomeNumber)
return true;
return false;
})
.ToList();