From ee54f1fac012d8c80dc6963a51ab869c128ebaed Mon Sep 17 00:00:00 2001 From: Christopher Jolly Date: Wed, 26 Apr 2023 01:16:37 +0800 Subject: [PATCH] Use MidB/InstrB for the byte versions. (still doesnt produce correct results yet) --- .../Internal/JetByteArrayMethodTranslator.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetByteArrayMethodTranslator.cs b/src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetByteArrayMethodTranslator.cs index b81a2cb..5cdd838 100644 --- a/src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetByteArrayMethodTranslator.cs +++ b/src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetByteArrayMethodTranslator.cs @@ -44,7 +44,7 @@ public class JetByteArrayMethodTranslator : IMethodCallTranslator IReadOnlyList arguments, IDiagnosticsLogger logger) { - if (method is { IsGenericMethod: true, Name: nameof(Enumerable.Contains) } + if (method is { IsGenericMethod: true, Name: nameof(Enumerable.Contains) } && arguments[0].Type == typeof(byte[])) { var source = arguments[0]; @@ -56,20 +56,20 @@ public class JetByteArrayMethodTranslator : IMethodCallTranslator return _sqlExpressionFactory.GreaterThan( _sqlExpressionFactory.Function( - "INSTR", - new[] { _sqlExpressionFactory.Constant(1), source, value, _sqlExpressionFactory.Constant(1) }, + "INSTRB", + new[] { _sqlExpressionFactory.Constant(1), source, value, _sqlExpressionFactory.Constant(0) }, nullable: true, argumentsPropagateNullability: new[] { true, true }, typeof(int)), _sqlExpressionFactory.Constant(0)); } - if (method is { IsGenericMethod: true, Name: nameof(Enumerable.First) } && method.GetParameters().Length == 1 + if (method is { IsGenericMethod: true, Name: nameof(Enumerable.First) } && method.GetParameters().Length == 1 && arguments[0].Type == typeof(byte[])) { return _sqlExpressionFactory.Convert( _sqlExpressionFactory.Function( - "MID", + "MIDB", new[] { arguments[0], _sqlExpressionFactory.Constant(1), _sqlExpressionFactory.Constant(1) }, nullable: true, argumentsPropagateNullability: new[] { true, true, true },