title: Difficulty with Linq on inner and left outer joins
body: <p>I can't see why this fails. The error is:</p>
  
  <blockquote>
    <p>Failure: Identifier 'Patient_recid' is not a parameter or variable or field of 'Nova.Data.Returntooffice'. If 'Patient_recid' is a property please add the FieldAlias or Storage attribute to it or declare it as a field's alias.</p>
  </blockquote>
  
  <p>Yep...that is correct. The tables are set up such that</p>
  
  <ol>
  <li><code>Returntooffices</code> references an <code>encountertimes</code> record (inner join).</li>
  <li>The <code>encountertimes</code> record references <code>patient</code> table record (inner join).</li>
  <li>The <code>Returntoooffice</code> record may or may not have an <code>appointment</code> record --This is the reason I am trying to use a left outer join.</li>
  </ol>
  
  <p>The <code>returntooffices</code> record DOES NOT have a <code>patient_recid</code>, and this is why I am attempting to join it to a <code>encountertimes</code> record.</p>
  
  <p>How is this done correctly?</p>
  
  <p>TIA</p>
  
  <pre><code>var query = 
      from rto in cxt.Returntooffices
      from encounter in cxt.Encountertimes.Where(f =&gt; f.Recid == rto.Encounter_recid)
      from patient in cxt.Patients.Where(p =&gt; p.Recid == encounter.Patient_recid &amp;&amp; p.Groupid == groupid)
      from appointment in cxt.Appointments.Where(a =&gt; a.Recid == rto.Appointment_recid).DefaultIfEmpty()
      select new
      {
          RTO = rto,
          APPOINTMENT = appointment
       };
  
   var b = query.ToList();
  </code></pre>