Skip to content

Commit 8badfa7

Browse files
fix for string based contains
1 parent ce57a44 commit 8badfa7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Magic.IndexedDb/LinqTranslation/Extensions/UniversalExpressionBuilder.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ private bool TryFlattenContains(MethodCallExpression call, out IEnumerable<Filte
300300
if (call.Method.Name != "Contains")
301301
return false;
302302

303+
if (call.Method.DeclaringType == typeof(string))
304+
return false;
305+
303306
// Case 1: Static-style => myArray.Contains(x.SomeProp)
304307
if (call.Object == null && call.Arguments.Count == 2)
305308
{

TestWasm/Pages/Home.razor

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,13 @@
280280
// allPeople.Where(x => x.DateOfBirth.HasValue && x.DateOfBirth.Value.Year == 2020));
281281
282282

283+
RunTest("One Char contains", await personQuery.Where(x => x.TestInt >= 1 && x.TestInt < 10).ToListAsync(),
284+
allPeople.Where(x => x.TestInt >= 1 && x.TestInt < 10));
285+
286+
287+
RunTest("One Char contains", await personQuery.Where(x => x.Name.Contains("J")).ToListAsync(),
288+
allPeople.Where(x => x.Name.Contains("J")));
289+
283290
RunTest("Ends With Test", await personQuery.Where(x => x.Name.EndsWith("ack")).ToListAsync(),
284291
allPeople.Where(x => x.Name.EndsWith("ack")));
285292

0 commit comments

Comments
 (0)