I know why this is happening but can somebody help me in the right direction of syntax? Currently I have three tables joined by one to one optional relationship. And I joined them as left outer join. My query is....
var model = from t1 in db.Doctors
join d in db.DoctorAddress on t1.DoctorId equals d.DoctorId into listi
join dc in db.DoctorCharges on t1.DoctorId equals dc.DoctorId into listj
join da in db.DoctorAvailablities on t1.DoctorId equals da.DoctorId into listk
from d in listi.DefaultIfEmpty()
from dc in listj.DefaultIfEmpty()
from da in listk.DefaultIfEmpty()
select new
{
Name = t1.Name,
RoomNo = da.RoomNo,
IPDCharge = dc.OPDCharge,
Address = d.Address,
};
My problem is that OPDCharge is of type Decimal(not null)
The error I get is:
Exception Details: System.InvalidOperationException: The cast to value type 'Double' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type.
What would be the correct syntax?
dc.OPDChargeandIPDCharge? Also what is the datatype of the column in the database?