Translating contains to like query
See original GitHub issueHello, the code bellow translates to Column` = "abc"` is there a way to make it translate to
Column like "%abc%"
public static class IQueryableExtensions
{
public static BinaryExpression GetBinaryExpression(ParameterExpression parameter, string property, object comparissonValue)
{
MemberExpression member = Expression.Property(parameter, property);
ConstantExpression constant = Expression.Constant(comparissonValue, comparissonValue.GetType());
MethodInfo method = typeof(StringHelpers).GetMethod("Contains", new[] { typeof(string), typeof(string) });
var containsExp = Expression.MakeBinary(ExpressionType.Equal, member, constant, false, method);
return containsExp;
}
}
public static class StringHelpers
{
public static bool Contains(string text, string text2)
{
return text.Contains(text2, StringComparison.InvariantCultureIgnoreCase);
}
}
Environment details
linq2db version: 3.1.6 Database Server: MySql 8.0.21 Database Provider: ? Operating system: Windows 10 .NET Framework: .Net Core 3.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
EF.Functions.Like in a compiled query could not be ...
You seems to be hitting yet another EF Core limitation. The problem is not the EF.Functions.Like method, but the usage of the interpolated ......
Read more >Why is Select().Contains() ok while Any() is not?
Hi all; I first tried the following code: var statesIndirectDelete = await States .Where(s => deletedCountries.Any(c => c.Id == s.
Read more >Cannot translate Contains for simple string comparison ...
After upgrading to 3.0 method using Where with string.Contains(string) inside throws translation error. Steps to reproduce Context.Entity.
Read more >Complex Query Operators - EF Core
Sometimes, a query in one form translates to the server but if written in a different form doesn't translate even if the result...
Read more >Translate queries with the interactive SQL translator
Describes how to translate a Teradata SQL query into a GoogleSQL query by using the BigQuery interactive SQL translator.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t know about special literature. Everything I have learned when improving this library.
@sdanyliv @viceroypenguin Thank you both very much for your time, it worked!