title: Linq to Entities SqlFunctions.DatePart
body: <p>This code is producing an error:</p>
  
  <pre><code>void GetLog()
  {
      List&lt;CAR_STATUS_LOGS&gt; logs = null;
      using (TESTEntities ctx = new TESTEntities())
      {
          logs = 
              ctx.CAR_STATUS_LOGS
                  .Where(a =&gt; SqlFunctions.DatePart("DAY", a.TIMEMARK) == 1)
                  .ToList();
      }
  }
  </code></pre>
  
  <p>The error is this:</p>
  
  <blockquote>
    <p>LINQ to Entities does not recognize the method 'System.Nullable`1[System.Int32] DatePart(System.String, System.Nullable`1[System.DateTime])' method, and this method cannot be translated into a store expression.</p>
  </blockquote>
  
  <p>I can't see what I am doing wrong with the <code>SqlFunctions.DatePart</code>. The column TIMEMARK is a Sqlserver DateTime type.<br>
  Any ideas?</p>