-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
why string contains can be translated to like '' #1896
Comments
@EmmaCCC I am referencing this simple console app code below: Program.csusing System;
using System.Diagnostics;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace IssueConsoleTemplate;
public class IceCream
{
public int IceCreamId { get; set; }
public string Name { get; set; }
}
public class Context : DbContext
{
public DbSet<IceCream> IceCreams { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
var connectionString = "server=127.0.0.1;port=3306;user=root;password=;database=Issue1896";
var serverVersion = ServerVersion.AutoDetect(connectionString);
optionsBuilder
.UseMySql(connectionString, serverVersion)
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging()
.EnableDetailedErrors();
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<IceCream>(
entity =>
{
entity.HasData(
new IceCream { IceCreamId = 1, Name = "Vanilla" },
new IceCream { IceCreamId = 2, Name = "Chocolate" },
new IceCream { IceCreamId = 3, Name = "Matcha" });
});
}
}
internal static class Program
{
private static void Main()
{
using var context = new Context();
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
var searchString = "la";
var results = context.IceCreams
.Where(i => i.Name.Contains(searchString))
.OrderBy(i => i.IceCreamId)
.ToList();
Trace.Assert(results.Count == 2);
Trace.Assert(results[0].Name == "Vanilla");
Trace.Assert(results[1].Name == "Chocolate");
}
} The EF Core team changed their base implementation of Pomelo
|
@lauxjpn Oh, I see. Thanks for your help. I will try to use EF.Functions.Like().I don't plan to upgrade the version just yet. |
The issue
This is my entity:
my test:
the translated sql:
so why (@__operatorName_0 LIKE '') , is this necessary?
Why not just be translated
or Why not just be translated only
I think (@__operatorName_0 LIKE '') is redundant ,is it a bug?
Further technical details
MySQL version: 8.0.27
Operating system: windows 10
Pomelo.EntityFrameworkCore.MySql version: 6.0.0
Microsoft.AspNetCore.App version: 6.0
Other details about my project setup:
The text was updated successfully, but these errors were encountered: