title: How to write if condition inside where clause in linq
body: <p>I want to write  if condition inside where clause. because if first name or last name is null I don't wani to add it in where  clause . other wise I want to add it.</p>
  
  <p>so I write </p>
  
  <pre><code>var query1 = from opv in _opvRepository.Table
                           join o in _orderRepository.Table on opv.OrderId equals o.Id
                           join gr in _graduandRepository.Table on opv.graduand_id equals gr.graduand_id
                           join pv in _productVariantRepository.Table on opv.ProductVariantId equals pv.Id
                           join p in _productRepository.Table on pv.ProductId equals p.Id
                           where (opv.ceremony_id == ceremony_id) &amp;&amp; 
                           (!o.Deleted) &amp;&amp; (opv.IsHireItem == true)  &amp;&amp;
                           (!p.Deleted) &amp;&amp;
                           (!pv.Deleted) &amp;&amp; (opv.ceremony_id == ceremony_id)      
                         //  group opv by opv.OrderId into g
                           select new
                           {
                               opvTable = opv,
                               grTable = gr,
  
                           };
  
  
  // This is not working. I have problem in here. How to add this??
               if (!String.IsNullOrEmpty(Fname))
                   query1 = query1.Where(grTable = &gt; grTable.first_name == Fname);
  
  
  
  
              var result = query1.ToList().Select(x =&gt;
              {
                  return new HireItemReportLine()
                  {
                      OrderId = x.opvTable.OrderId,
                      OrderDate=x.opvTable.Order.CreatedOnUtc,
                      Amount= x.opvTable.Order.OrderSubtotalExclTax,
                      PaymentMethod = x.opvTable.Order.PaymentMethodSystemName,
                      paidDate = x.opvTable.Order.CreatedOnUtc,
  
                      Fname = x.grTable.first_name,
                      MName = x.grTable.middle_name,
                      LName = x.grTable.last_name,
  
  
  
                  };
              }).ToList();
  </code></pre>
  
  <p>What is the wrong with my cording??</p>