Reputation: 307
I am working on a project using Asp.net mvc 3 and planning to have oracle 11g database as back-end.
I was able to access oracle server with no problem and data loaded successfully into an html table.
The problem comes when I try to add, edit or delete a record. I believe it is a very simple issue, but till now, I couldn't figure it out. The following simple model is used:
class Country
{
public int CountryId { get; set; }
public string CountryName { get; set; }
}
The CountryId feild was created at Oracle using NUMBER(10) as I thought this will work as SQL Server Integer. But an exception was raised, indicates that it couldn't take the value as Edm.decimal !
I tried to make it NUMBER(19) and changed the CountryId to long and still getting the same exception.
I spent long hours searching for an open source project that is using asp.net mvc with oracle, but I couldn't find any!
Any idea, why oracle is not supporting integer, long? how to make it working as expected with my MVC project?
Upvotes: 2
Views: 997
Reputation: 16310
From Oracle Data Type Mappings,
This data type is an alias for the NUMBER(38) data type, and is designed so that the OracleDataReader returns a System.Decimal or OracleNumber instead of an integer value. Using the .NET Framework data type can cause an overflow.
So, you need to use decimal
datatype in .net framework to support the NUMBER
datatype in Oracle.
It would be better if you mapped your data type in following way:
[.NET: Int32] = [Oracle:NUMBER(2)..NUMBER(9)*]
[.NET: Int64] = [Oracle:NUMBER(10)..NUMBER(18)*]
[.NET: Double] = [Oracle:NUMBER(x, 0)..NUMBER(x, 15)*]
[.NET: Double] = [Oracle: FLOAT]
[.NET: Decimal] = [Oracle:NUMBER]
Upvotes: 5
Reputation: 1476
Have you tried using a decimal or an Int32? I am getting my suggestions from some documentation that I found online: http://docs.oracle.com/cd/E11882_01/win.112/e18754/featLINQ.htm . Let me know how this might work for you.
Upvotes: 0