Search code examples
c#lambdadbsetor-operator

How do I use the || operator in a lambda expression


How do I use the || (or) operator in a lambda expression?

Here is what I have tried:

db.assets.Where((u => u.userName.Equals(userName)) || (c => c.category.Equals("DefaultMapMarker"))

Thanks in advance

EDIT

I am wanting to get a list of assets for the current user, as well as all assets that are for all users. Assets for all users have a category of DefaultMapMarker.


Solution

  • You can use it inside the body:

    db.assets.Where(u => u.userName.Equals(userName)
                         || u.category.Equals("DefaultMapMarker"))
    

    The way you did it would translate into "Lambda || Lambda" or "Func || Func"