I am running a project with EF6 and ODP.NET, and I am having problems performing search queries based on fixed-length CHAR columns.
The following code does not return any results, even if this user exists in the database.
using (var context = new Entities())
{
var search = "testuser";
var result = context.Users
.Where(u => u.UserName == search)
.FirstOrDefault();
}
I know I can get around this by filling in the search bar or trimming the database column, but I'm looking for an alternative solution.
I noticed that if I execute a query directly using OracleConnection / OracleCommand, then it works. Is there an attribute or anything that I can add to the entity class to force ODP.NET to bind a variable like OracleDbType.Char?
Basically, I'm looking for a way to reproduce the following behavior from EF6:
var cmd = new OracleCommand("SELECT * FROM users WHERE user_name = :p0", conn);
cmd.Parameters.Add(":p0", OracleDbType.Char).Value = "testuser";
Devart dotConnect Oracle. , , . , ODP.NET dotConnect. , ODP.NET , ODP.NET. , ODP.NET?
modelBuilder.Entity<Users>()
.Property(u => u.UserName
.IsFixedLength();
, VARCHAR2 , , , . , , !