Home > Software engineering >  EF Core Value Converter In Oracle Wont Work
EF Core Value Converter In Oracle Wont Work

Time:11-05

i use Ef core and Oracle

i have a Column in Oracle Database With Data Type NVARCHAR2(20) but in my Class Model i want Convert It Decimal this is Config For ValueConverter :

entity.Property(e => e.ColumnName)
                .HasMaxLength(20)
                .HasColumnType("NVARCHAR2(20)")
                .HasColumnName("COLUMN_NAME")
                .HasConversion(
                v => v.ToString(),
                v => v=="" ? 0 : decimal.Parse(v, NumberStyles.Any, CultureInfo.InvariantCulture));

and this my My Model :

public decimal? ColumnName{ get; set; }

but after use this query this error show :

ORA-00932: inconsistent datatypes: expected NUMBER got NCHAR'

CodePudding user response:

I Convert Column Via Oracle Query with check for number combability

(case when REGEXP_LIKE(ColumnName, '^[[:digit:]] $') then to_number(ColumnName) else 0 end) as ColumnName
  • Related