Oracle Number cast to .Net decimal
up vote
2
down vote
favorite
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?
c# oracle entity-framework-6 ef-code-first
add a comment |
up vote
2
down vote
favorite
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?
c# oracle entity-framework-6 ef-code-first
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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?
c# oracle entity-framework-6 ef-code-first
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?
c# oracle entity-framework-6 ef-code-first
c# oracle entity-framework-6 ef-code-first
asked Nov 12 at 16:20
Dominic Cotton
441418
441418
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53266187%2foracle-number-cast-to-net-decimal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown