I am having lambda expression where I am getting record when all the values are equal in input object and db object
var matchingrecord = (from data in dbContext.TableA
where data.Id == inputDto.Id &&
data.AddTypeId == inputDto.AddressTypeId &&
inputDto.AddressLineOne == data.AddressLineOne) &&
(inputDto.AddressLineTwo == (data.AddressLineTwo ?? string.Empty)) &&
(inputDto.State ==null||(inputDto.State.stateId == data.State.StateId)) &&
(inputDto.City == data.City) &&
(inputDto.ZipCd == data.ZipCd)
select data).FirstOrDefault();
I need to include in where clause another field check(zipcodeExtn) only when zipcodeExtn is not null.
(inputDto.City == data.City) &&
(inputDto.ZipCd == data.ZipCd) &&
(inputDto.zipcodeExtn=data.zipcodeExtn) // This should be added only when zipcodeExtn is not null
Please let med know if its possible to write one statement instead of adding if condition