title: Best way to compare date in Entity Framework
body: <p>I am using date in where clause in Entity Framework and getting following error:</p>
  
  <p><a href="https://i.stack.imgur.com/ohWoz.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/ohWoz.jpg" alt="enter image description here"></a></p>
  
  <p>It is due to the below code:</p>
  
  <pre><code>var entity = dbContext.MyTable
                        .Where(w =&gt; w.PId = 3 &amp;&amp; w.CreatedOn.Date == mydate.Date)
                        .First();
  </code></pre>
  
  <p>If I convert data into list using <code>.ToList()</code>, then compare to date, it will work fine but if I do so then it will pull data first into code then filter it out. Please help me out with this issue. Currently I am using a stored procedure to resolve the issue but really want this to work.</p>