title: LINQ to Entities does not recognize the method 'System.String ToString(System.String)'
body: <p>I am trying to compare a month of date stored in the sql while fetching the records but it throws me the exception.</p>
  
  <pre><code>public partial class LateRequest
  {
      public int LateRequestID { get; set; }
      public Nullable&lt;int&gt; EmpID { get; set; }
      public Nullable&lt;int&gt; TeamLeadAppr { get; set; }
      public Nullable&lt;int&gt; DeptLeadAppr { get; set; }
      public Nullable&lt;System.DateTime&gt; lateDate { get; set; }
  }
  </code></pre>
  
  <p>in my calculations Class I have;</p>
  
  <pre><code>public int getMonthlyLatesApproved(int empId)
  {
      DateTime today = DateTime.Now;
      var getMonth = today.Month
      var lateApproved = (from obj in db.LateRequests
                          where obj.EmpID == empId
                          &amp;&amp; obj.TeamLeadAppr == 1 &amp;&amp; obj.DeptLeadAppr == 1
                          &amp;&amp; obj.lateDate.Value.ToString("mm") == getMonth.ToString()
                          select obj).Count();
      return lateApproved;
  }
  </code></pre>
  
  <p>This did not work so I tried with LINQ like:</p>
  
  <pre><code>return db.LateRequests.Where(x =&gt; x.EmpID == empId &amp;&amp; x.TeamLeadAppr == 1 &amp;&amp; x.DeptLeadAppr == 1 &amp;&amp;
                                    x.lateDate.Value.ToString("mm") == getMonth.ToString()).Count();
  </code></pre>
  
  <p>This failed and I read it <a href="https://stackoverflow.com/questions/40401166/linq-to-entities-does-not-recognize-the-method-system-string-tostringsystem-st">here</a> and tried with <code>AsEnumerable()</code></p>
  
  <p>like below;</p>
  
  <pre><code> return db.LateRequests.Where(x =&gt; x.EmpID == empId &amp;&amp; x.TeamLeadAppr == 1 &amp;&amp; x.DeptLeadAppr == 1 &amp;&amp;
                                    x.lateDate.Value.ToString("mm") == getMonth.ToString()).AsEnumerable().Count();
  </code></pre>
  
  <p>`<a href="https://stackoverflow.com/questions/40401166/linq-to-entities-does-not-recognize-the-method-system-string-tostringsystem-st">LINQ to Entities does not recognize the method &#39;System.String ToString(System.String)&#39; method.when i try to format my date</a></p>
  
  <p>I need to understand how am I mixing the c-sharp with sql commands while retrieving the records?</p>