I'm using the dynamic LINQ library by Scott Guthrie together with Entity Framework and C#.
I have to build my where string into a variable based on several factors and then pass the string variable to the where clause. For some reason, this will work:
ContactList = ContactList.Where("DateAdded >= @0", DateTime.Parse("12/1/2012"));
But this will not work
string WhereClause = string.Format("DateAdded >= {0}", DateTime.Parse("12/1/2012"));
ContactList = ContactList.Where(WhereClause);
As mentioned, I need to use it in the version of passing the variable. Anyone know why the second doesn't work?
Thanks in advance!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…