where clause in linq query
- by masoud
in the below code "transmittalno.TransID" always has value but "doctranstocon.Transid" sometimes has value and sometimes does not, so when "doctranstocon.Transid" has value I have no problem but when there is not any value, when compare in the where clause like :"transmittalno.TransID == doctranstocon.Transid". It returns error" Object reference not set to an instance of an object."
TranstoCons = from doctranstocon in _DocTranstoCons where
( transmittalno.TransID == doctranstocon.Transid ) select doctranstocon.tblTranstoCon
I like TranstoCons returns null when there is not any value for " doctranstocon.Transid "
How I can handle this error in the below linq query:
var query = from transmittalno in _Transmittals
Select new TransmittaltoConPresentationModel { TransID = transmittalno.TransID, Transmittal = transmittalno.TRANSMITTAL, TranstoCons = from doctranstocon in _DocTranstoCons where
( transmittalno.TransID == doctranstocon.Transid ) select doctranstocon.tblTranstoCon };