src/Inflatable/LinqExpression/WhereClauses/Property.cs
/// <summary>
/// Optimizes the operator based on the mapping source.
/// </summary>
/// <param name="mappingSource">The mapping source.</param>
/// <returns>The result</returns>
Optimizes the operator based on the mapping source.
Optimizes the operator based on the mapping source .
public IOperator Optimize(IMappingSource mappingSource)
        {
            var ParentMappings = mappingSource.GetChildMappings(typeof(TObject))
                                              .SelectMany(x => mappingSource.GetParentMapping(x.ObjectType));
            var ParentMapping = ParentMappings.FirstOrDefault(x => x.ContainsProperty(InternalProperty.Name));
            if (ParentMapping is null)
            {
                return null!;
            }
            Column = ParentMapping.GetColumnName(InternalProperty.Name);
            var BinaryParent = Parent as BinaryOperator;
            if (InternalProperty.PropertyType == typeof(bool)
                && (BinaryParent is null
                    || BinaryParent.Operator == ExpressionType.And
                    || BinaryParent.Operator == ExpressionType.AndAlso
                    || BinaryParent.Operator == ExpressionType.Or
                    || BinaryParent.Operator == ExpressionType.OrElse))
            {
                return new BinaryOperator(this, new Constant(true, Count), ExpressionType.Equal);
            }
            return this;
        }
public IOperator Optimize ( IMappingSource mappingSource ) { var ParentMappings = mappingSource . GetChildMappings ( typeof ( TObject ) ) . SelectMany ( x => mappingSource . GetParentMapping ( x . ObjectType ) ) ; var ParentMapping = ParentMappings . FirstOrDefault ( x => x . ContainsProperty ( InternalProperty . Name ) ) ; if ( ParentMapping is null ) { return null ! ; } Column = ParentMapping . GetColumnName ( InternalProperty . Name ) ; var BinaryParent = Parent as BinaryOperator ; if ( InternalProperty . PropertyType == typeof ( bool ) && ( BinaryParent is null || BinaryParent . Operator == ExpressionType . And || BinaryParent . Operator == ExpressionType . AndAlso || BinaryParent . Operator == ExpressionType . Or || BinaryParent . Operator == ExpressionType . OrElse ) ) { return new BinaryOperator ( this , new Constant ( true , Count ) , ExpressionType . Equal ) ; } return this ; }
Optimizes the operator based on the mapping source.
Optimizes the operator based on the mapping source .
None
mappingSource
IMappingSource
The mapping source.
The mapping source .