title: LINQ query can I match object type property with another object in where condition
body: <p>I have an object <strong><code>BankAccount</code></strong> which I want to check for match in LINQ query. </p>
  
  <p>There is another object <strong><code>LenderAccount</code></strong> which has reference of <strong><code>BankAccount</code></strong> entity.</p>
  
  <p>Finally an object <strong><code>LoanConnection</code></strong> has reference of <strong><code>LenderAccount</code></strong>. I am looking for all connections that have particular <strong><code>BankAccount</code></strong>.</p>
  
  <p>Following is the code:</p>
  
  <pre><code>var bankAccount = accountService.GetBankAccountById(1);
  var lenderCons = lenderConnectionService.List().Where(c =&gt; c.LenderAccount.BankAccount == bankAccount).ToList();
  </code></pre>
  
  <p>Above query seems to work. But I thought in LINQ we need to check in where condition with basic data types (like: integer, string, double etc) like following code.</p>
  
  <pre><code>var bankAccount = accountService.GetBankAccountById(1);
  var lenderCons = lenderConnectionService.List().Where(c =&gt; c.LenderAccount.BankAccount.Id == bankAccount.Id).ToList();
  </code></pre>
  
  <p>Am I doing anything wrong here or is it allowed in LINQ to check object type property in where conditions with <strong><code>==</code></strong> operator?</p>