Using Where method in Linq 2 Entities with OR clause.

Posted by Dani on Stack Overflow See other posts from Stack Overflow or by Dani
Published on 2011-01-04T12:37:24Z Indexed on 2011/01/04 12:54 UTC
Read the original article Hit count: 197

Filed under:

I want to use Where method in Linq 2 entities that will be equal to this

userRepository.Users.Where(u=>u.RoleID == 1 || u=>u.RoldID == 2).Select(o => new SelectListItem { Text = o.Role.RoleName, Value = o.RoleID.ToString() }).ToList();

The problem of course is in Where(u=>u.RoleID == 1 || u=>u.RoldID == 2)

The problem is that I don't know how to use WHERE method with OR inside the WHERE clause.

any ideas (the code above will not compile of-course b/c of the lambda expression.

userRepository.Users returns an list of Users entities.

I guess that and can be done using concatenation of .Where().Where() but I need an OR.

© Stack Overflow or respective owner

Related posts about linq-to-entities