So I have a list with post
objects that have a visibility
enum property. I’m trying to get all posts that have visibility == visibility.public
and visibility == visibility.private && AuthorId == currentUserId
.
This doesn’t seem to work: from e in list select (e.Visibility == Visibility.Public && (e.Visibility == Visibility.Private && e.Author.Id == userId))
Any help would be appreciated
2
Answers
You are asking that a post has visibility public AND private at the same time. Your two conditions should use an OR not an AND.
Your condition should be
e.Visibility == Visibility.Public || (e.Visibility == Visibility.Private && e.Author.Id == userId)
Notice the
||
Try this