public SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList <SqlExpression> arguments, IDiagnosticsLogger <DbLoggerCategory.Query> logger) { if (!method.Equals(StartsWithMethod)) { return(null); } var patternExpression = arguments[0]; var startsWithExpression = _fbSqlExpressionFactory.AndAlso( _fbSqlExpressionFactory.Like( instance, _fbSqlExpressionFactory.Add(patternExpression, _fbSqlExpressionFactory.Constant("%"))), _fbSqlExpressionFactory.Equal( _fbSqlExpressionFactory.Function( "LEFT", new[] { instance, _fbSqlExpressionFactory.Function( "CHAR_LENGTH", new[] { patternExpression }, true, new[] { true }, typeof(int)) }, true, new[] { true, true }, instance.Type), patternExpression)); return(patternExpression is SqlConstantExpression sqlConstantExpression ? (string)sqlConstantExpression.Value == string.Empty ? (SqlExpression)_fbSqlExpressionFactory.Constant(true) : startsWithExpression : _fbSqlExpressionFactory.OrElse( startsWithExpression, _fbSqlExpressionFactory.Equal( patternExpression, _fbSqlExpressionFactory.Constant(string.Empty)))); }