title: C# linq how to search data between two date
body: <p>I am working on Windows base application I want search details between two date 
  so am using linq query for that.</p>
  
  <p>My query is:</p>
  
  <pre><code>mealsdbEntities objEntity = new mealsdbEntities();
  System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-CA");
  
  DateTime OrderFromDate = DateTime.Parse(dtOrderFDate.Value.ToString("MM/dd/yyyy"));
  DateTime OrderToDate = DateTime.Parse(dtOrderToDate.Value.ToString("MM/dd/yyyy"));
  DateTime DelFromDate = DateTime.Parse(dtOrderDelFDate.Value.ToString("MM/dd/yyyy"));
  DateTime DelToDate = DateTime.Parse(dtOrderDelTDate.Value.ToString("MM/dd/yyyy"));
  
  var OrderList = (from ol in objEntity.orders
                   join cust_Con in objEntity.customermasters 
                        on ol.customer_id equals cust_Con.id
                   join cust_Cont in objEntity.customercontacts 
                        on ol.customer_id equals cust_Cont.customer_id
                   join oDish in objEntity.orderdishes 
                        on ol.id equals oDish.order_id
                   where cust_Con.company_name.Contains("" + txt_Cust_name.Text + "") 
                         &amp;&amp; (EntityFunctions.TruncateTime(OrderFromDate) == OrderFromDate) 
                         //&gt;= OrderFromDate) &amp;&amp; (ol.createdon &lt;= OrderToDate)) 
                         //&amp;&amp; (ol.deliverydate &gt;= DelFromDate &amp;&amp; ol.deliverydate &lt;= DelToDate)
                   select new
                   {
                       ID = ol.id,
                       Title = ol.title,
                       Name = cust_Con.company_name,
                       Phone = cust_Cont.contact_phone,
                       // Item = disgcateg.dish_name,
                       DeliveryDate = ol.deliverydate,
                       DeliveryTime = ol.deliverytime,
                       Amount = ol.orderamount,
                       Status = ol.status
                   }).ToList();
  </code></pre>
  
  <p>but I am getting an error:</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.Data.EntityCommandExecutionException' occurred in System.Data.Entity.dll</p>
    
    <p>Additional information: An error occurred while executing the command definition. See the inner exception for details.</p>
  </blockquote>
  
  <p>Can anyone kindly tell me where I am wrong?</p>