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: Thanks both. v3.0 is taking longer than I'd hoped as I'm not getting enough time to spend on it. Therefore I'll suck this update into v2, along with another fix I have, and push that out as a release.

Viewing all articles
Browse latest Browse all 1642

Trending Articles