Quantcast
Channel: EntityFramework Reverse POCO Code First Generator
Viewing all articles
Browse latest Browse all 1642

Commented Unassigned: GetPropertyType assumes decimal for Numeric [62]

$
0
0
In the EF.Reverse.POCO.Core.ttinclude::GetPropertyType, the "numeric" case assumes that the scale is greater than zero. For database types such as Numeric(17,0), the C# type should resolve to something in the "int" family.

Here is the code that I adjusted:

From:
```
case "numeric":
case "smallmoney":
case "decimal":
case "money":
sysType = "decimal";
break;
```

To:
```
case "numeric":
case "decimal":
{
       if ( Scale == 0 )
       {
          if ( Precision >= 15 )
             sysType = "Int64";
          else if ( Precision >= 8 )
             sysType = "Int32";
          else
             sysType = "Int16";
       }
       else 
       {
          sysType = "Decimal";
       }
    }
    break;
case "smallmoney":
case "money":
sysType = "decimal";
break;
```
Comments: ErikEJ - Thank you! I understand and have adjusted the code above to include decimal. Thanks again for your input.

Viewing all articles
Browse latest Browse all 1642

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>