sql server - C# Linq to SQL Query Not Returning results but generated SQL works fine? -
i trying run below code linq sql. know results return zero. when run correlating select statement linq generates in sql server management studio , substitute parameters values returns result. ideas?
var qryres = (from res in dbhistorycontext.tblresumes res.updateddate >= dtdatefrom.date && res.updateddate <= dtdateto.date select res);
it returns sql code:
select [t0].[resumehistoryid], [t0].[resumeid], [t0].[monsterid], [t0].[resumetitle], [t0].[updateddate], [t0].[updatedstatus], [t0].[source], [t0].[lastmodified], [t0].[modifiedby], [t0].[datechanged], [t0].[monsterhistoryid], [t0].[changetype] [dbo].[tblresume] [t0] ([t0].[updateddate] >= @p0) , ([t0].[updateddate] <= @p1)
where @p0 = '4/01/2015 12:00:00 am' , @p1 = '04/30/2015 12:00:00 am'
but reason returned select statement works when directly copies , pasted , ran against dbcontexts database linq sql doesn't seem return results when do:
var lst = qryres.tolist();
the count zero. ideas? know connection good. know datacontext pointing right database - looked several times , refreshed dbml several times. seems happen when trying date between date. know can tricky. missing here?
i going have go being issue comparison dates. can guarantee dtdatefrom.date or dtdateto.date in same format what's behind res.updateddate?
also, give following try:
var qryres = dbhistorycontext.tblresumes.where(res => res.updateddate >= dtdatefrom.date && res.updateddate <= dtdateto.date).tolist();
Comments
Post a Comment