diff --git a/src/SQLite.cs b/src/SQLite.cs index ae962f1d..292222e2 100644 --- a/src/SQLite.cs +++ b/src/SQLite.cs @@ -3333,6 +3333,9 @@ private CompileResult CompileExpr (Expression expr, List queryArgs) else if (call.Method.Name == "ToUpper") { sqlCall = "(upper(" + obj.CommandText + "))"; } + else if (call.Method.Name == "Replace" && args.Length == 2) { + sqlCall = "(replace(" + obj.CommandText + "," + args[0].CommandText + "," + args[1].CommandText + "))"; + } else { sqlCall = call.Method.Name.ToLower () + "(" + string.Join (",", args.Select (a => a.CommandText).ToArray ()) + ")"; } diff --git a/tests/LinqTest.cs b/tests/LinqTest.cs index ad1f350b..0090795b 100644 --- a/tests/LinqTest.cs +++ b/tests/LinqTest.cs @@ -294,5 +294,27 @@ public void CastedParameters () Assert.AreEqual ("Foo", r.Value); } + + [Test] + public void Issue460_ReplaceWith2Args () + { + var db = CreateDb (); + db.Trace = true; + db.Tracer = Console.WriteLine; + + db.Insert (new Product { + Name = "I am not B X B", + }); + db.Insert (new Product { + Name = "I am B O B", + }); + + var cl = (from c in db.Table () + where c.Name.Replace (" ", "").Contains ("BOB") + select c).FirstOrDefault (); + + Assert.AreEqual (2, cl.Id); + Assert.AreEqual ("I am B O B", cl.Name); + } } }