Oracle Number cast to .Net decimal

Viewed 444

I am mapping an Entity Framework project to an existing Oracle database. I have a class:

public class Order 
{
   [Key]
   public string OrderNo {get;set;} // Oracle type VARCHAR2(100)
   public decimal Cost {get;set;} // Oracle type NUMBER (no precision)
}

public DbSet<Order> Orders {get;set;}

Then executing the following:

context.Orders.Find("0001");

returns the error Specified cast is not valid!. This looks like its caused by a very large decimal value in the COST column. I have tried setting the following attribute on the entity:

[Column("ROUND(COST,2)"]
public decimal Cost {get;set;}

Which causes an exception with the generated SQL OracleException: ORA-00904: "Extent1"."ROUND(COST,2)": invalid identifier. I would like it to generate ROUND("Extent1".COST,2).

Is there a way to force the database to convert the column as part of the SQL statement?

0 Answers
Related