| | | StrataFrame Beginner
       
Group: StrataFrame Users Last Login: 05/06/2010 4:48:16 PM Posts: 35, Visits: 146 |
| Hi All
I'm using SF in an Oracle environment, which converts all numeric values returned from the database into a. Net decimal type. Many times I want to use the value as an int, so I set the BOM to use a custom type of "int" which generates the following code...
return (int)this.CurrentRow["OBJECTID"];
which causes a runtime cast violation (i.e. unboxing from a decimal to an int is not allowed.)
If instead, BOM would generate the following...
return (int)((decimal)this.CurrentRow["OBJECTID"]);
all would be well.
I'd like BOM to generated custom type fields using the following template...
return (custom-type)((native-db-type)this.CurrentRow[fieldName]);
Thanks! |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: 08/31/2010 2:36:53 PM Posts: 6,287, Visits: 6,191 |
| | Actually instead of changing the BO Mapper, I recommend getting the field the way you like it then adding it into the BO Mapper as a Custom Code override since this is the exception instead of the rule. |
| | | | StrataFrame Beginner
       
Group: StrataFrame Users Last Login: 05/06/2010 4:48:16 PM Posts: 35, Visits: 146 |
| Hi Trent
Yes, I currently have to use Custom Code overrides for each and every numeric field that I don't use as the default decimal type. But, since there are dozens (hundreds?) of fields like this, it would save considerable time to have the BOM generate the "correct" code.
Put yourself in my place: if MicroFour had to write custom code for each and every integer field in your application, what would you do? I'll bet that you would change the BOM in a hurry!
|
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: 08/31/2010 2:36:53 PM Posts: 6,287, Visits: 6,191 |
| | Why are you trying to convert this into an integer in the first place. That might help me better understand your situation. Is this just because of Oracle and you are creating Numeric data types with no decimals? |
| | | | StrataFrame Beginner
       
Group: StrataFrame Users Last Login: 05/06/2010 4:48:16 PM Posts: 35, Visits: 146 |
| Hi Trent
I use integers for the same reason anyone uses them. By having a BO show certain values as integers conveys a particular meaning and use. For example, a field representing "count of things" is naturally an integer; a value of "1.5" is unmeaningful. But, I'm sure you know these things.
In Oracle, I can declare a field of type NUMBER(9,0) -- which naturally is treated as an integer. However, the .NET Oracle driver returns the value as a decimal. I have no choice or control over this conversion.
In SQLServer you're fortunate because you can declare an integer value in the database and have it returned as an integer; not so in Oracle.
Have pity on us SF Oracle users, even though we are few in number |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: 08/31/2010 2:36:53 PM Posts: 6,287, Visits: 6,191 |
| | This could actually require a very significant change to the BO Mapper, which is already slated to happen in the next update. So this is something that we will consider for the next version of the BO Mapper. I will look into this and think about it for a while, but I am not going to make a quick change here as it could result in many other problems outside of the Oracle user base. |
| | | | StrataFrame Beginner
       
Group: StrataFrame Users Last Login: 05/06/2010 4:48:16 PM Posts: 35, Visits: 146 |
| Hi Trent
Thank you for considering the change.
I'm not sure why the change would be "significant?" Under normal circumstances, all Oracle numeric fields coming out of BOM looking like...
return (System.Decimal)this.CurrentRow["OBJECTID"];
If I set the field's Custom Data Type to int, then I'd expect the field to look like...
return (int)((System.Decimal)this.CurrentRow["OBJECTID"]);
Why is this so hard?
|
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: 08/31/2010 2:36:53 PM Posts: 6,287, Visits: 6,191 |
| Well, you are basically asking me how the partial class dynamically builds source code, which is like asking how long is a string. It would require a change to allow for double casting on a per field basis. Anytime you change dynamic source code and interject a change like this, it isn't as simple as just whacking in some code.
As I mentioned, we will take it into consideration. We will not make a rash change here as anytime we update code that could effect the entire user base at a high-level, we study the change and implement methodically. |
| |
|
|