title: Where not null using Linq
body: <p>I have a mySQL database with a <code>Website</code> field that is of type VarChar. Some of these fields will be null on the database.</p>
  
  <p>I have an MVC application that I sending the database information to.</p>
  
  <p>I am trying to set up a filter on the Index page so I can filter by certain columns. I am using the <code>Request.QueryString</code> to do this. </p>
  
  <pre><code> switch (Request.QueryString["FilterOptionSelect"])
              { case "CountyName":
                      if (!string.IsNullOrEmpty(filteredText))
                      {
                          filteredText = filteredText.ToUpper();
                          var modelFiltered = from n in model
                                                 where n.CountyName.ToUpper().Contains(filteredText)
                                                 select n;
                          return View(modelFiltered);
                      }
                      break;
                 case "Website":
                      if (!string.IsNullOrEmpty(filteredText))
                      {
                          filteredText = filteredText.ToUpper();
                          var modelFiltered = from n in model
                                              where n.CountyWebsite.ToUpper().Contains(filteredText)
                                              select n;
                          return View(modelFiltered);
                      }
                      break;
  
  }
  </code></pre>
  
  <p>The only problem I have is on the Website case. It gives me a <code>Object reference not set to an instance of an object.</code> on the WHERE CLAUSE of the Website case. When I debug, my model is not null (it has 130+ items inside...some with website info and some without website info). </p>
  
  <p>I have already tried using the Lambda method (which had the same problem). I have also tried using <code>where n.CountyWebsite.ToUpper().Contains(filteredText) &amp;&amp; n.CountyWebsite != null</code> which did not work either.</p>