Accessing ORACLE with SQL SERVER generated Business Object (Problem)


Author
Message
Ertan Deniz
Ertan Deniz
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)
Group: Forum Members
Posts: 163, Visits: 493
Business Object was filled from ORACLE. (Table)

But When I 'm trying to access "id" property getting the error "specified cast is not valid".

Id property (Int32), Datatable.Column.type is System.Decimal. (ORacle table column is NUMBER").

I've run the query through FillDataTable("Select statement") command.

public System.Int32 id

{

get

{

return (System.Int32)this.CurrentRow["id"];

}

set

{

this.CurrentRow["id"] = value;

}

}

Dustin Taylor
Dustin Taylor
StrataFrame Team Member (660 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
All numbers in Oracle are stored as floating point numbers, so they come out as decimal. To ensure that you can return it as an integer, use the System.Convert.ToInt32() method instead of casting it as an integer.
Ertan Deniz
Ertan Deniz
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)
Group: Forum Members
Posts: 163, Visits: 493
But Business Object is generated based on SQL SERVER table.

The cast operation was generated by StrataFrame. If I change the cast operation to System.Convert.ToInt32(), next generation will overwrite.

What can I do in this case ?

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'd suggest using the custom code area in the BO mapper. Then it won't get overwritten.
StrataFrame Team
S
StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
OK, so the business object was built against a SQL Server table through the business object mapper, but you're using ORACLE to populate the business object at runtime? 

If so, then there's you're problem.  When you build the business object against a database at design-time, then it's highly recommended that you execute the business object against the same database type at runtime.  So, if you use the BOMapper to build the schema against the ORACLE table, then all of those Int columns will be changed to System.Decimal instead.  Then, your code that accesses the business object can worry about the type conversions.

Ertan Deniz
Ertan Deniz
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)
Group: Forum Members
Posts: 163, Visits: 493
My need is very clear. I want to support both ORACLE and SQL SERVER at the runtime over single business object in my project. I've read linked post. Trent has said that

"The BOs do not know or care about where the data comes from.  The only time that you will have an issue in regards to the BO is if you are creating custom queries (SqlCommand / OracleCommand) and then executing that command via a FillTableThe BOs do not know or care about where the data comes from.  The only time that you will have an issue in regards to the BO is if you are creating custom queries (SqlCommand / OracleCommand) and then executing that command via a FillTable"

 http://forum.strataframe.net/Topic16974-6-1.aspx

So, I've worked on a few days to be successful on my requirement. Generating business objects from two data sources and manage the true instance complicates my work. It is not acceptable.

If there will be a solution, it have to be developed easily.

What should I do ? Does strataframe solves my requirement ? Please respond quickly.

Ertan Deniz
Ertan Deniz
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)
Group: Forum Members
Posts: 163, Visits: 493
I' ve also found one critical point.

CreateDbParameter function of OracleDataSourceItem tries to set nativeDbType. But  it assumes object is generated based on ORACLE Table. (See code below.)

'-- First set the native db type

loReturn.OracleType = CType(QueryInfo.FieldNativeDbTypes(FieldName), OracleType)

So, We can not support SQL and ORACLE with the single object.

I wonder If Microfour or any other customer implement this case.

Can we progress with the customization of the framework or MicroFour can do this for the users of strataframe ?

Not : Plus, StrataFrame have to handle the case sensitivity needs on field names and tablenames.

Ertan Deniz
Ertan Deniz
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)
Group: Forum Members
Posts: 163, Visits: 493
Any comment ? No comment, When I need quick responce !
Dustin Taylor
Dustin Taylor
StrataFrame Team Member (660 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
If you are wanting to do this without re-creating the objects in the BO Mapper using Oracle as the DB source, I would create a shared method someplace that will do a type conversion for you. A good place for this would be your base business object, use the FieldAccessing event (you can enable the event in the BO Mapper), to call your shared method whenever the field is accessed and parse the necessary conversions and such for you.

The bottom line is that this is a fairly custom scenario (creating the BO Mapper metadata using one database type and deploying to a seperate data base type) that you will need to account for. It will take some work up front, but it can certainly be done.

Ertan Deniz
Ertan Deniz
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)
Group: Forum Members
Posts: 163, Visits: 493
I don't think this is a custom scenario. I expect you to solve all these requirements in the framework.

There are many points in my post to say something about.

What about Createparameter method ? What is your solution ?

Any StrataFrame customer implemeting the case ? Microfour ?

Please let us work on this issue together. This is not easy as putting a shared method somewhere.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search