title: ADO.NET Entity Framework multiple statement in where clause or a grouped lambda expression
body: <p>I am new to the ADO.NET Entity Framework Model. Using DotNet Framework 3.5</p>
  
  <p>I have two tables :</p>
  
  <p>viz. <b>customers</b> and <b>city</b></p>
  
  <p>The customers table refers to a cityname column in the table city (foreign key relationship)</p>
  
  <p>While creating a win c# form i am giving the user to filter customers based on his search choices (viz. name, city, number, etc.) Here is my structure</p>
  
  <pre><code>
  using(DataContext dc = new DataContext())  
  {  
      IEnumerable cust = dc.customers;  
      if(name != null)    {  
          cust = cust.Where&lt;customers>(c => c.name == name);
      }  
      if(mobile != null)    {  
          cust = cust.Where&lt;customers>(c => c.mobile == mobile);
      }  
      if(city != null)    {
          cust = cust.Where&lt;customers>(c => c.city.cityname == city); //ERROR HERE
      }
  }
  </code></pre>
  
  <p>I get a NullPointerException, since the EntityReference.Load method is not called upon. Quite logical point and I agree to it.
  I would like some advice on how to either call the load method in the current architechure. Is it possible to somehow do this :
  <pre><code>    c.cityReference.Load();
      c.city.cityname == city
  </pre></code></p>
  
  <p>Or possibly some lambda expression (I am new to it) which induces both the statements? Ne suggestions?
  I am ready to change the current architecture if anyone has a better advice. </p>