src/Inflatable/LinqExpression/WhereClauses/LikeOperator.cs
/// <summary>
/// Optimizes the operator based on the mapping source.
/// </summary>
/// <param name="mappingSource">The mapping source.</param>
/// <returns></returns>
Optimizes the operator based on the mapping source.
Optimizes the operator based on the mapping source .
public IOperator? Optimize(IMappingSource mappingSource)
        {
            Property = Property?.Optimize(mappingSource);
            if (Property is null)
                return null;
            Value = Value?.Optimize(mappingSource);
            if (Value is Constant TempConstant)
            {
                var Val = TempConstant.Value?.ToString();
                if (!string.IsNullOrEmpty(Val))
                {
                    if (MethodType == "StartsWith")
                        TempConstant.Value = Val + "%";
                    else if (MethodType == "EndsWith")
                        TempConstant.Value = "%" + Val;
                    else if (MethodType == "Contains")
                        TempConstant.Value = "%" + Val + "%";
                }
            }
            return this;
        }
public IOperator ? Optimize ( IMappingSource mappingSource ) { Property = Property ? . Optimize ( mappingSource ) ; if ( Property is null ) return null ; Value = Value ? . Optimize ( mappingSource ) ; if ( Value is Constant TempConstant ) { var Val = TempConstant . Value ? . ToString ( ) ; if ( ! string . IsNullOrEmpty ( Val ) ) { if ( MethodType == " " ) TempConstant . Value = Val + " " ; else if ( MethodType == " " ) TempConstant . Value = " " + Val ; else if ( MethodType == " " ) TempConstant . Value = " " + Val + " " ; } } 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 .