none
Entity Framework and LINQ - Arithmetic operation resulted in an overflow RRS feed

  • Question

  •             using (MyEntities ctx = new MyEntities())
                {
                    var OraLINQEX1 = from e in ctx.TABLE_A
                                     select e;

                    Console.WriteLine("LINQ to Entities Result");
                    foreach (var result in OraLINQEX1)
                    {
                        //Console.WriteLine(String.Format("ID: {0}    Name: {1}", result.FIELDA, result.FIELDB));
                    }

    Hi Guys,

    Anybody knows why I receive the error:

    Arithmetic operation resulted in an overflow.

    Please, help me :)

    Regards,


    • Edited by Digão77 Thursday, August 23, 2012 7:57 PM
    Thursday, August 23, 2012 7:32 PM

Answers

  • I haven't used Oracle before so I am no expert on this, but I think that the problem is that decimal cannot handle all possible values of an unrestrained number field in Oracle.

    The information here (http://docs.oracle.com/cd/E11882_01/win.112/e18754/featLINQ.htm) makes me think that you will need to limit the precision of your number field to 1, 38 to have it map nicely.

    There could be some alternatives, but you would need someone with more oracle knowledge to help you out. I would search, and post, on Stackoverflow with both the Oracle and entity-framework tags to get people that use EF with Oracle to help you out.


    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Friday, August 24, 2012 3:40 PM
    Moderator

All replies

  • Hi,

    This seems like it is more likely to have come from the database than EF.

    So some more information about the database, and what is in the fields you are accessing might help.

    One thing I would do is try and run a trace against your database that allows you to see the SQL that is being generated by EF. Then you can run that SQL against the database and see why it is causing the problem.


    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Thursday, August 23, 2012 8:32 PM
    Moderator
  • Hi Glenn,

    My database is Oracle, I´m using reference

    http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/EntityFrameworkOBE/EntityFrameworkOBE.htm

    I used another table and it works, but I think that the problem is with number datatype, it´s maped like decimal.

    The field are created only like number, without size.

    Witch is the better datatype in this case in dotnet?

    Thanks.

    Friday, August 24, 2012 12:06 PM
  • I haven't used Oracle before so I am no expert on this, but I think that the problem is that decimal cannot handle all possible values of an unrestrained number field in Oracle.

    The information here (http://docs.oracle.com/cd/E11882_01/win.112/e18754/featLINQ.htm) makes me think that you will need to limit the precision of your number field to 1, 38 to have it map nicely.

    There could be some alternatives, but you would need someone with more oracle knowledge to help you out. I would search, and post, on Stackoverflow with both the Oracle and entity-framework tags to get people that use EF with Oracle to help you out.


    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Friday, August 24, 2012 3:40 PM
    Moderator
  • Thank you Glenn.

    Friday, August 24, 2012 9:00 PM