i'm trying add timespan datetime in linq query using entity framework. i've got following code:
edit
timeslotsis icollection<timeslot>
timeslot has properties datetime start , timespan duration
var linq = s in schedulesbase join c in channelbase on s.channelid equals c.channelid select new { ... timeslots = s.timeslots, ... }; var timeslots = linq.selectmany(t => t.timeslots); return s in timeslots select new resources.event { ... end = dbfunctions.addseconds((datetime?)s.start, (int32?)s.duration.seconds) ... }; it compiles fine doesn't add time s.duration.seconds end. since following code works
end = dbfunctions.addseconds((datetime?)s.start, 500) and behaves expected must doing wrong conversion timespan seconds.
what doing wrong in first case?
i suspect problem you're using seconds instead of totalseconds. seconds property gives value in range [-59, 59] - 5 minutes , 30 seconds return 30, not 330, example.
try:
end = dbfunctions.addseconds((datetime?)s.start, (int32?)s.duration.totalseconds)
Comments
Post a Comment