while doing LINQ I got this Error.
“Cannot implicitly convert type ‘System.DateTime?’ to ‘System.DateTime’. An explicit conversion exists (are you missing a cast?)”
I know its because of the data type but Convert is not working is there any other way to do it.
here is my code.
{var tvr = from t in ce.tbl_TVRinfo
where t.TVRID == fTVRid
select new TVRDetails
{
TVRID = t.TVRID,
Ename = t.Ename,
Esdw = t.Esdw,
Edob =t.Edob, //this field is causing date conversion error
Epob = t.Epob,
Equalification = t.Equalification,
NIC = t.NIC,
EAddress = t.EAddress
}
return tvr.ToList();
}
You are trying to assign a Nullable DateTime to a standard DateTime. If you are confident that the Nullable DateTime contains a value then you could do:
Or if you are not sure it has a value: