0

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.

Simon
  • 7,991
  • 21
  • 83
  • 163

1 Answers1

6

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"

Random Dev
  • 51,810
  • 9
  • 92
  • 119
  • @Sayse ofc - we don't know (and maybe this is wrong as `category` on a user(?) seems strange) - if not than the complete filter operation is very strange or impossible – Random Dev Sep 01 '14 at 07:51
  • Yeah, that was what I was wondering. Otherwise, The op would need two different queries (with the possibility of joining them together afterwards – Sayse Sep 01 '14 at 07:52