-1

I am using Entity Framework with MYSQL database. I am trying to get result from following query.

select COUNT(*) from tbldata where CreatedBy is not null and created is not null and DATE(Created) = DATE(NOW())

Above query returned accurate result. I have tried this query in E.F but it returns zero Count.

var todayDate = DateTime.Now.Date;

_db.TblData.Where(c => c.CreatedBy != null && c.Created != null && c.Created == todayDate)
                .Count();

How can I compare only date value in E.F?

Thank you

Shoaib Ijaz
  • 5,347
  • 12
  • 56
  • 84

1 Answers1

0

try to use like this, extension methods not work for linq.

   _db.TblData.Count(c => c.CreatedBy != null && c.Created != null && c.Created.Date == DateTime.Today);
sumngh
  • 566
  • 2
  • 10