I'm using L2S and I have to perform one left outer join with VisitFromTime and VisitToTime v开发者_运维百科alues in right table. Code looks like:
from d in db.Doctors
join p in db.plans on d.DoctorID equals p.DoctorID
into temp
from t in temp.DefaultIfEmpty()
select new MyModel
{
....
....
VisitTimeFrom = t!=null?t.VisitTimeFrom:new TimeSpan(),
VisitTimeTo = t!=null?t.VisitTimeTo:new TimeSpan()
}
It gives me runtime exception that explicit conversion from bigint to time is not supported in SQL.
is VisitTimeFrom and VisitTimeTo bigint in the database?
If so surely you want
VisitTimeFrom = t!=null?t.VisitTimeFrom:0,
VisitTimeTo = t!=null?t.VisitTimeTo:0
Make sure t.VisitTimeFrom
and t.VisitTimeTo
are both timespans.
精彩评论