title: How to query and calculate dates in the where clause of a LINQ statement?
body: <p>I am having trouble with the following piece of code. Before I paste it, Let me give a bit of history on what should happen.</p>
  
  <p>I have a model containing 2 fields of interest at the moment, which is the name of the order the customer placed, and the date at which he/she placed it. A pre-calculated date will be used to query the <code>dateplaced</code> field (and should only query the dates , and not the time). The query counts the amount of duplicates that occur in the MondayOrder field, and groups them together. Now , when I exclude the where clause which should query the dates, the query runs great. However, The goal of this query is to count the amount of orders for the following week based on the date the order has been placed.</p>
  
  <pre><code>List&lt;string&gt; returnlist = new List&lt;string&gt;();
  DateTime dt = getNextWeekMondaysDate().Date;
  switch (day)
  {
      case DayOfWeek.Monday: 
      {
          var CountOrders =
             from x in Data.EntityDB.Orders 
             group x by x.MondayOrder into m 
             let count = m.Count() 
             select new
             {
                 MondayOrderItem = m.Key, Amount = count 
             };
  
          foreach (var item in CountOrders)
          {
              returnlist.Add(item.MondayOrderItem + " : " +
                 item.Amount);
          }
      }
      break;
  </code></pre>
  
  <p>The <code>getNextWeekMondaysDate()</code> method has an overload which I can use, where if I supply it a date, it will get the following Monday's date from the parameter given. The problem is though, LINQ does not accept queries such as the following:</p>
  
  <pre><code>var CountOrders =
      from x in Data.EntityDB.Orders 
      where getNextWeekMondaysDate(x.DatePlaced.Value).Date == dt
      group x by x.MondayOrder into m 
      let count = m.Count() 
      select new { MondayOrderItem = m.Key, Amount = count };
  </code></pre>
  
  <p>This is exactly what I must achieve. Is there any workaround for this situation? </p>
  
  <p><strong>UPDATE</strong> </p>
  
  <p>Here is the exception I get when I try the 2nd query.</p>
  
  <p>LINQ to Entities does not recognize the method 'System.DateTime getNextWeekMondaysDate(System.DateTime)' method, and this method cannot be translated into a store expression.</p>