I have the following code, which truncates the time:
// does this already exist?
var seekScan = (from s in aDb.Item_Scan_Event
where s.item_detail_id == th_piece_id &&
s.scan_type == scantype &&
DbFunctions.TruncateTime(s.scan_datetime) == dt_scan.s.ScanDatetime.Date
select s).FirstOrDefault();
What I need instead is to have it compare the dateTime including the HH:mm
I have tried using something simple like a string comparison but you can't do that inside of a Linq-to-Entities:
var seekScan = (from s in aDb.Item_Scan_Event
where s.item_detail_id == th_piece_id &&
s.scan_type == scantype &&
s.scan_datetime.Value.ToString("MM/dd/yyyy HH:mm") == dt_scan.s.ScanDatetime.ToString("MM/dd/yyyy HH:mm")
select s).FirstOrDefault();
The error I get is:
LINQ to Entities does not recognize the method 'System.String ToString(System.String)' method, and this method cannot be translated into a store expression.'