i have following code:
datetime timestamp = convert.todatetime(request.querystring["timestamp"]); var result = (from rs in db.vrec rs.timestamp == timestamp && rs.fixure == wfixture select rs).tolist(); the result shows 0 though correct timestamp passed.
if remove part timestamp comparison:
rs.timestamp == timestamp the code works fine.
any idea on why datetime comparison may not working?
from question, not know if want compare date time or date part. if want compare date following work
var result = (from rs in db.vrec rs.timestamp.date == timestamp.date && rs.fixure == wfixture select rs).tolist(); since using reference db, gives me feeling fetching records database (which orm using not obvious question or tags). assuming using entity framework above query fail exception .date has no direct translation sql. if can rewrite query following make work.
var result = (from rs in db.vrec rs.timestamp.day == timestamp.day && rs.timestamp.month == timestamp.month && rs.timestamp.year == timestamp.year && rs.fixure == wfixture select rs).tolist(); the benefit of approach can compare properties arbitrary deep level i.e can compare hours, minutes,seconds etc. in query. second query tested in entity framework 5.
Comments
Post a Comment