1 Reply Latest reply: Feb 8, 2013 6:24 AM by Tridus RSS

    Entity Framework 4, ODP.Net - Retrieving decimal into string

      What I am trying to do is use Entity Framework to fill objects but not lose the precision that comes with Oracle in regards to decimals. I want to map EF string fields to Oracle Decimal but can't figure out if it can be done.

      What I have tried:

      I changed by CSDL and SSDL to map my columns in the EDMX to map to string. This works fine till I run and get the following error:

      {"Specified cast is not valid."}

      It appears that ODP.Net when working with Entity Framework tries the following:

      System.String GetString(Int32)

      So it appears the problem is the conversion of the decimal coming from Oracle and trying to put it into an Int32. Is there anyway around this?
        • 1. Re: Entity Framework 4, ODP.Net - Retrieving decimal into string
          Just to be clear, you have a table with a number column in it, and you want it to be a string on the EF side?

          I tried to do it with an EDM Mapping to convert numbers into strings, and the EF Provider did not like that. Honestly I didn't expect it to, but it seemed like something worth trying. :)

          Next I tried just making a model from a table with a number on it, and changing that to a string. It didn't like that either. If you also had no luck by doing it in the CSDL & SSDL, I'm out of ideas for how to do it directly.

          The most practical workaround is to create a view that calls TO_CHAR on the number column, and have EF work against the view.