private Expression GetCondition(Expression value, IMemberMapperData mapperData) { var nestedAccessChecks = mapperData.GetNestedAccessChecksFor(value); if (nestedAccessChecks == null) { return(null); } if (IsNotOptionalEntityMemberId(mapperData)) { return(nestedAccessChecks); } var sourceMemberValue = SourceMember.GetQualifiedAccess(mapperData); var sourceValueType = sourceMemberValue.Type.GetNonNullableType(); if (!sourceValueType.IsNumeric()) { return(nestedAccessChecks); } if (sourceMemberValue.Type.IsNullableType()) { sourceMemberValue = sourceMemberValue.GetNullableValueAccess(); } var zero = 0.ToConstantExpression(sourceValueType); var sourceValueNonZero = Expression.NotEqual(sourceMemberValue, zero); return(Expression.AndAlso(nestedAccessChecks, sourceValueNonZero)); }
public Expression GetConditionOrNull(IMemberMapperData mapperData) { if (!HasCondition) { return(null); } var condition = _conditionLambda.GetBody(mapperData); if (_negateCondition) { condition = condition.Negate(); } var conditionNestedAccessesChecks = mapperData.GetNestedAccessChecksFor(condition); if (conditionNestedAccessesChecks != null) { condition = Expression.AndAlso(conditionNestedAccessesChecks, condition); } return(condition); }