- dotConnect for Oracle 9.6.646
- EntityFramework Core 2.1.4
- .Net Core 2.1.2
# Issue description
Say I need to mapping System.Guid to CHAR(36), it's done with GuidToStringConverter as shown in following POC.
And it's correctly converted to string type when Find(id) or Where(item => item.Id == id), but still converted to binary when Contains(item.Id).
It looks like a bug to me, would you please check, Thanks.
Code: Select all
class Program
{
static void Main(string[] args)
{
var id = Guid.Parse("06a1472e-62a9-4add-942d-ba5b83f0c2c4");
using(var dbContext = new MyDbContext()) {
dbContext.Database.EnsureCreated();
var found = dbContext.Items.Find(id);
Console.WriteLine(found?.Id); // got '06a1472e-62a9-4add-942d-ba5b83f0c2c4'
// Executed DbCommand (79ms) [Parameters=[p__get_Item_0='06a1472e-62a9-4add-942d-ba5b83f0c2c4' (Size = 36)], CommandType='Text', CommandTimeout='0']
// SELECT "e"."Id"
// FROM "Items" "e"
// WHERE ("e"."Id" = :p__get_Item_0) AND ((ROWNUM) <= 1)
var count = dbContext.Items.Count(item => new[]{id}.Contains(item.Id));
Console.WriteLine(count); // should be 1, got 0
// Executed DbCommand (11ms) [Parameters=[p__id_0='06a1472e-62a9-4add-942d-ba5b83f0c2c4' (Nullable = true) (DbType = Binary)], CommandType='Text', CommandTimeout='0']
// SELECT Count(*)
// FROM "Items" "item"
// WHERE "item"."Id" IN (:p__id_0)
}
}
}
public class MyDbContext : DbContext {
public static readonly LoggerFactory MyLoggerFactory = new LoggerFactory(new[] {new ConsoleLoggerProvider((_, __) => true, true)});
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder
.EnableSensitiveDataLogging()
.UseLoggerFactory(MyLoggerFactory)
.UseOracle("REDACTED");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Item>().Property(item => item.Id)
.ForOracleHasColumnType("CHAR(36)")
.HasConversion(new GuidToStringConverter());
}
public DbSet<Item> Items { get; set; }
}
public class Item
{
public System.Guid Id { get; set; }
}