title: LINQ to SQL: Left join on multiple columns
body: <p>First of all, I have searched google/SO, checked some examples, but I didn't manage to write the proper linq expression:</p>
  
  <p><strong>This is how my working sql query looks like:</strong></p>
  
  <pre><code>select *
  from Places p
  left join VoteLog v
  on p.Id = v.PlaceId
  and v.UserId = '076a11b9-6b14-4230-99fe-28aab078cefb' --demo userid
  </code></pre>
  
  <p><strong>This is my attempt with linq:</strong></p>
  
  <pre><code>public IQueryable&lt;Place&gt; GetAllPublic(string userId)
  {
      var result = (from p in _db.Places
                   join v in _db.VoteLogs
                   on p.Id equals v.PlaceId // This works but doesn't fully reproduce my SQL query
                   // on new { p.Id, userId} equals new {v.PlaceId, v.UserId} -&gt; Not ok
                   where p.Public == 1
                   select new
                   {
                      Id = p.Id,
                      UserId = p.UserId,
                      X = p.X,
                      Y = p.Y,
                      Titlu = p.Titlu,
                      Descriere = p.Descriere,
                      Public = p.Public,
                      Votes = p.Votes,
                      DateCreated = p.DateCreated,
                      DateOccured = p.DateOccured,
                      UserVoted = v.Vote
                   })
          .ToList()
          .Select(x =&gt; new Place()
          {
              Id = x.Id,
              UserId = x.UserId,
              X = x.X,
              Y = x.Y,
              Titlu = x.Titlu,
              Descriere = x.Descriere,
              Public = x.Public,
              Votes = x.Votes,
              DateCreated = x.DateCreated,
              DateOccured = x.DateOccured,
              UserVoted = x.UserVoted
          }).AsQueryable();
  </code></pre>