Saturday, October 13, 2018

Inner join on same table with Linq?

In EF core I'm trying to write a linq statement that would be roughly equivalent to this:

SELECT matcher.matchedWith, matcher.liked FROM Matches as matcher INNER JOIN Matches as matchee ON matcher.matchedWith = matchee.matcher WHERE (matcher.liked = 1) OR (matcher.liked = 2) AND (matchee.liked = 1) OR (matchee.liked = 2) AND matcher.matcher=1 AND matchee.matchedWith=1 

Seems like it should be simple to do but I'm running in circles trying to get it right. Is there any easy way to do this or should I just execute raw sql?

Inner join on same table with Linq? Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team