An expression tree lambda may not contain a null propagating operator
-
I am getting the following error when I am write the following Linq - can somebody please suggest me to write the same without getting the error. My Linq is as follows:
myOrphanList = ( from v in allViolations from r in allInspectionResults from i in allItems where r.InspectionResultId == i.InspectionResultId && i.InspectionItemId == v.InspectionItemId select new OrphanViolationsReport { ViolationId = v.ViolationId, ViolationNumber = v.ViolationNumber, ViolationDate = v.ViolationDate, ViolationType = v.ViolationType.ViolationTypeCode, ItemYear = i.ItemYear, ItemMakeManufacturer = i.ItemMakeManufacturer, ItemModel = i.ItemModel, VIN = i.VIN, PIN = i.PIN, InspectionResultId = r.InspectionResultId, InspectionResultNumber = r.InspectionRequestNumber, DealerDmvNumber = r.DealerDmvNumber, InspectedCompanyName = (from a in contacts where a.ContactId == r.InspectedCompanyDataId select a.FirstName)?.FirstOrDefault() } ).ToList();
At the line "InspectedCompanyName = (from a in contacts where a.ContactId == r.InspectedCompanyDataId select a.FirstName)?.FirstOrDefault()" I am getting following error - how can I get rid of it - thank you
An expression tree lambda may not contain a null propagating operator
Any help please
-
I am getting the following error when I am write the following Linq - can somebody please suggest me to write the same without getting the error. My Linq is as follows:
myOrphanList = ( from v in allViolations from r in allInspectionResults from i in allItems where r.InspectionResultId == i.InspectionResultId && i.InspectionItemId == v.InspectionItemId select new OrphanViolationsReport { ViolationId = v.ViolationId, ViolationNumber = v.ViolationNumber, ViolationDate = v.ViolationDate, ViolationType = v.ViolationType.ViolationTypeCode, ItemYear = i.ItemYear, ItemMakeManufacturer = i.ItemMakeManufacturer, ItemModel = i.ItemModel, VIN = i.VIN, PIN = i.PIN, InspectionResultId = r.InspectionResultId, InspectionResultNumber = r.InspectionRequestNumber, DealerDmvNumber = r.DealerDmvNumber, InspectedCompanyName = (from a in contacts where a.ContactId == r.InspectedCompanyDataId select a.FirstName)?.FirstOrDefault() } ).ToList();
At the line "InspectedCompanyName = (from a in contacts where a.ContactId == r.InspectedCompanyDataId select a.FirstName)?.FirstOrDefault()" I am getting following error - how can I get rid of it - thank you
An expression tree lambda may not contain a null propagating operator
Any help please
-
I am getting the following error when I am write the following Linq - can somebody please suggest me to write the same without getting the error. My Linq is as follows:
myOrphanList = ( from v in allViolations from r in allInspectionResults from i in allItems where r.InspectionResultId == i.InspectionResultId && i.InspectionItemId == v.InspectionItemId select new OrphanViolationsReport { ViolationId = v.ViolationId, ViolationNumber = v.ViolationNumber, ViolationDate = v.ViolationDate, ViolationType = v.ViolationType.ViolationTypeCode, ItemYear = i.ItemYear, ItemMakeManufacturer = i.ItemMakeManufacturer, ItemModel = i.ItemModel, VIN = i.VIN, PIN = i.PIN, InspectionResultId = r.InspectionResultId, InspectionResultNumber = r.InspectionRequestNumber, DealerDmvNumber = r.DealerDmvNumber, InspectedCompanyName = (from a in contacts where a.ContactId == r.InspectedCompanyDataId select a.FirstName)?.FirstOrDefault() } ).ToList();
At the line "InspectedCompanyName = (from a in contacts where a.ContactId == r.InspectedCompanyDataId select a.FirstName)?.FirstOrDefault()" I am getting following error - how can I get rid of it - thank you
An expression tree lambda may not contain a null propagating operator
Any help please
Just ditch question mark in front of
FirstOrDefault
.