我知道为什么会这样,但是有人可以帮助我正确的语法方向吗?目前我有三个表通过一对一的可选关系连接。我加入了他们作为左外连接。我的查询是......
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,
};
我的问题是OPDCharge
类型Decimal(not null)
我得到的错误是:
异常详细信息:System.InvalidOperationException:转换为值类型“Double”失败,因为具体化值为 null。结果类型的泛型参数或查询必须使用可为空的类型。
什么是正确的语法?