I use the library System.Linq.Dynamic.Coreto generate queries in my project. A date string is passed to me, and I want to make a dynamic equivalent of this:
db.EntityName
.Where(x => x.StartDate > DateTime.ParseExact("02/19/2018", "MM/dd/yyyy", CultureInfo.InvariantCulture))
I found that this request below works:
db.EntityName
.Where($"x => x.StartDate.ToFileTime() > { DateTime.ParseExact("02/19/2018", "MM/dd/yyyy", CultureInfo.InvariantCulture).ToFileTime() }")
Is this the right approach? It converts to StartDate, so I'm not sure if this will lead to poor performance. Is this good or is there a better way to do this?
source
share