Trober
Trober

Reputation: 269

DynamicQueryable .Where for exactly a Date (only, no time)

I can find >= <= etc. but not equal for a date only using System.Linq.Dynamic DynamicQueryable Where.

Does anyone have an example? Searched the whirled wild web and found nothing yet.

Example:

SELECT * FROM ORDERS WHERE CONVERT(date, Created) = '2016-07-08'

Upvotes: 0

Views: 438

Answers (1)

Trober
Trober

Reputation: 269

Appears a slight modification of this will answer this question: Dynamic LINQ DateTime Comparison String Building - Linq To Entities.

If you want orders for a specific date (no time involved):

dbContext.Orders.Where("( Created >= DateTime(2016, 07, 08) AND Created < DateTime(2016, 07, 09) )")

And per article above, if you have other columns in the WHERE clause, you'll have to build that yourself.

Upvotes: 1

Related Questions