var offices= from x in _officeRepository.GetAll()
select new OfficeModels()
{
Id = x.id,
AddressOne = x.address_1,
AddressTwo = x.address_2,
Company = x.a1.Select(y => new CompanyModels { Id=y.id, Name = y.name}).FirstOrDefault()??
x.a2.Select(y => new CompanyModels { Id = y.id, Name = y.name }).FirstOrDefault() ??
x.a3.Select(y => new CompanyModels { Id = y.id, Name = y.name }).FirstOrDefault() ??
x.a4.Select(y => new CompanyModels { Id = y.id, Name = y.name }).FirstOrDefault(),
City = x.city,
Active = x.active,
Country = x.country,
Deleted = x.deleted,
OfficeFax = x.fax,
OfficeName = x.office_name,
OfficePhone = x.office_phone
};
我收到此错误The argument to DbIsNullExpression must refer to a primitive or reference type
,该错误是由于 CompanyModels.. 我在这里做错了什么,我错过了什么吗?
如果假设我在初始化 CompanyModels 时包含此行
new CompanyModels { CompanyId = y.id, Name = y.name,CompType = Enumerations.Companies.MediaSellers }
即CompType = Enumerations.Companies.MediaSellers
这给出了某种不同的错误说法The specified value is not an instance of type 'Edm.Int32'Parameter name: value