/// <summary> /// Optimizes the operator based on the mapping source. /// </summary> /// <param name="mappingSource">The mapping source.</param> /// <returns></returns> public IOperator Optimize(IMappingSource mappingSource) { InternalOperator = InternalOperator.Optimize(mappingSource); if (InternalOperator is null) { return(null !); } return(Operator == ExpressionType.Not ? InternalOperator.LogicallyNegate() : (this)); }
/// <summary> /// Optimizes the operator based on the mapping source. /// </summary> /// <param name="mappingSource">The mapping source.</param> public IOperator Optimize(IMappingSource mappingSource) { if (InternalOperator is null) { return(this); } var IsValid = mappingSource.GetChildMappings(ObjectType).Any(); InternalOperator = IsValid ? InternalOperator.Optimize(mappingSource) : null; if (InternalOperator?.TypeCode != typeof(bool)) { InternalOperator = null; } return(this); }