I am not sure what is wrong with the following syntax. I would like to query my DataContext for the following data:
Show me everything that has nothing in FilesAccesses and nothing in FileAccessGroups.
Also show me everything that has my user ID in FilesAccesses.
Here is the syntax I am trying to use. It fails on the || at the end of the third line saying: “Operator ‘||’ cannot be applied to operands of type ‘lambda expression’ and ‘lambda expression'”
Is my syntax wrong? These types of queries have to be possible right?
return db.Files
.Where(
(f => !f.FilesAccesses.Any() && !f.FilesAccessGroups.Any()) ||
(f => f.FilesAccesses.Any(a => a.UserId == user)))
.OrderBy(f => f.ObjectType)
.ThenBy(f => f.Name);
Try this, your syntax is indeed wrong.