public SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList <SqlExpression> arguments, IDiagnosticsLogger <DbLoggerCategory.Query> logger) { if (!method.Equals(MethodInfo)) { return(null); } var patternExpression = _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]); var positionExpression = _fbSqlExpressionFactory.GreaterThan( _fbSqlExpressionFactory.Function( "POSITION", new[] { patternExpression, instance }, true, new[] { true, true }, typeof(int)), _fbSqlExpressionFactory.Constant(0)); return(patternExpression is SqlConstantExpression sqlConstantExpression ? ((string)sqlConstantExpression.Value)?.Length == 0 ? (SqlExpression)_fbSqlExpressionFactory.Constant(true) : positionExpression : _fbSqlExpressionFactory.OrElse( positionExpression, _fbSqlExpressionFactory.Equal( patternExpression, _fbSqlExpressionFactory.Constant(string.Empty)))); }
public SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList <SqlExpression> arguments) { if (!method.Equals(MethodInfo)) { return(null); } var patternExpression = arguments[0]; var positionExpression = _fbSqlExpressionFactory.GreaterThan( _fbSqlExpressionFactory.Function( "POSITION", new[] { patternExpression, instance }, typeof(int)), _fbSqlExpressionFactory.Constant(0)); return(patternExpression is SqlConstantExpression sqlConstantExpression ? ((string)sqlConstantExpression.Value)?.Length == 0 ? (SqlExpression)_fbSqlExpressionFactory.Constant(true) : positionExpression : _fbSqlExpressionFactory.OrElse( positionExpression, _fbSqlExpressionFactory.Equal( patternExpression, _fbSqlExpressionFactory.Constant(string.Empty)))); }
public SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList <SqlExpression> arguments, IDiagnosticsLogger <DbLoggerCategory.Query> logger) { if (method.IsGenericMethod && method.GetGenericMethodDefinition().Equals(EnumerableMethods.Contains) && arguments[0].Type == typeof(byte[])) { var value = arguments[1] is SqlConstantExpression constantValue ? _fbSqlExpressionFactory.Function("ASCII_CHAR", new[] { _fbSqlExpressionFactory.Constant((byte)constantValue.Value) }, false, new[] { false }, typeof(string)) : _fbSqlExpressionFactory.Function("ASCII_CHAR", new[] { _fbSqlExpressionFactory.Convert(_fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[1]), typeof(byte)) }, true, new[] { true }, typeof(string)); return(_fbSqlExpressionFactory.GreaterThan( _fbSqlExpressionFactory.Function( "POSITION", new[] { value, _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]) }, true, new[] { true, true }, typeof(int)), _fbSqlExpressionFactory.Constant(0))); } return(null); }