0

I have downloaded Microsoft Dynamic Query API. And using the dynamic query to filter the data using dates. I have written following query :-

Entities db = new Entities();
DateTime d = new DateTime(2014, 1, 17);
var lst = db.MSTPriorityS.Where("ModifiedOn == @0", d.Date.ToString()).ToList();

The result count, i am getting is 0. While there is data in the database table. Please advise what i am doing wrong?

Stark
  • 441
  • 9
  • 29

2 Answers2

0

you can use lambda expression instead: var lst = db.MSTPriorityS.Where(u => u.ModifiedOn == System.Data.Objects.EntityFunctions.TruncateTime(d))

Amir Sherafatian
  • 2,083
  • 2
  • 20
  • 32
  • bcoz of some typical requirement of project i need to use dynamic query. so do u hv any work around for that? – Stark Jan 29 '14 at 06:14
0

i think the problem is where you cast DateTime to String probably, you can create your query step by step, and type safe, follow 'Creating dynamic queries with entity framework'

Community
  • 1
  • 1
Amir Sherafatian
  • 2,083
  • 2
  • 20
  • 32