C# Lambda Problem
Posted
by Chris Klepeis
on Stack Overflow
See other posts from Stack Overflow
or by Chris Klepeis
Published on 2010-06-15T20:38:22Z
Indexed on
2010/06/15
20:42 UTC
Read the original article
Hit count: 304
Probably something simple, but as I'm new to lambda expressions, the problem evades me:
m => m.contactID == contactID && m.primaryAddress == true && (m.addressTypeID == 2 || m.addressTypeID == 3)
I tried to use that lambda expression but I receive an invalid operator. Is there a way to simplify this so that it would work?
Edit:
The equivolent sql query would be:
SELECT *
FROM Contact
WHERE contactID = 3
AND primaryAddress = 1
AND (addressTypeID = 2 OR addressTypeID = 3)
I have a repository function defined like so:
public E Single(Expression<Func<E, bool>> where)
{
return objectSet.Single<E>(where);
}
I'm passing the lambda expression above into this function. Invalid operator error.
© Stack Overflow or respective owner