Can you add an "Or" condition to an entity in the entity framework? For example something like:
Property1 == (1 or 2 or 3)
The message I get when putting the value of "1 || 2 || 3" or "1,2,3" or "1 or 2 or 3" returns this message:
condition is not compatible with the type of the member
You need to do:
var results = entityCollection.Where(entity => entity.Property1 == 1 || entity.Property1 == 2 || entity.Property1 == 3);
You should also check out predicate builder: http://www.albahari.com/nutshell/predicatebuilder.aspx
It's a bit more advanced, but if you have to dynamically chain conditions it's your best bet.
foreach (string keyword in keywords)
{
string temp = keyword;
predicate = predicate.Or (p => p.Description.Contains (temp));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With