title: How to avoid null values in LINQ command?
body: <p>I am trying to search the object from its list using entity framework. </p>
  
  <p>I have following structure of the object</p>
  
  <pre><code>public class Product
  {
      public int Id { get; set; }
      public string ProductName { get; set; }
      public double Size { get; set; }
  }
  </code></pre>
  
  <p>and I create the list of the product </p>
  
  <pre><code>private List&lt;Product&gt; AddProducts()
  {
      List&lt;Product&gt; ProductList = new List&lt;Product&gt;();
  
      oProduct Product = new Product();
      oProduct.Id = 1;
      oInventory.ProductName = "Product1";
      oProduct.Size = 25;
      ProductList.Add(oProduct);
  
      oProduct Product = new Product();
      oProduct.Id = 2;
      oInventory.ProductName = "Product2";
      oProduct.Size = 25;
      ProductList.Add(oProduct);
  
      return ProductList;           
  }
  </code></pre>
  
  <p>Now, I am trying to search the object form the above list form ProductName parameter. </p>
  
  <p>I have used below code. </p>
  
  <pre><code>public ActionResult Index(string productname = "", string size = "")
  {
      var oProdList = from ProdList in AddProducts() select oProdList;
      oProdList = oProdList.Where(oProd =&gt; oProd.ProductName.ToUpper().Contains(ProductName.ToUpper().Trim())|| oProd.Size.ToString().ToUpper().Contains(size.ToUpper().Trim()));
      ViewBag.ProductList = oProdList;
      return View();
  }
  </code></pre>
  
  <p>Now Please check picture below, I have list of products and I am trying to find the Product1 by typing it in text box and I keep the size textbox blank.
  now when I click on submit , I pass these two varibles for searching in Index method (above one) but the LINQ command returns the both records,  Product1 and Product 2 
  but it should return only one record </p>
  
  <p>How to deal with this ? </p>
  
  <p><img src="https://i.stack.imgur.com/LUMRX.png" alt="enter image description here"></p>