Copying Data from one BO to another BO


Author
Message
Robin J Giltner
Robin J Giltner
StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)
Group: Forum Members
Posts: 105, Visits: 650
I have two BusinessObjects, of different types and databases.  I have to copy the data from one row into the other row.  I do this manually now by creating a newrow on the target BO, and then passing the current datarow for each to a method that sets the fields on the target BO from the source BO.  Then the targetBO has Save called.

This is done on several BO's with parent-child relationships.  My main problem are speed issues.  When I go to add a Topmost row in the parent-child relation order (? I guess its called an order, I dunno), it must add that single record, then all child records, grandchild records, great-grandchild records, and great-great-grandchild records.  These are done all the same way, newrow, copy all the fields, then save.

When all is said and done, I've added approximately 200-400 rows into the database and this is sometimes taking 20-30 seconds.

Is this the proper way to copy data from one BO to another or different types, or is there a better way?

Thanks. And have a good weekend.

Robin Giltner

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The speed issues are coming from the fact that all of the business objects are checking their business logic each time they save their records... all 200-400 of them.  Generally, if you need raw speed, you have to hand code the ADO.NET.  So, if you don't need the business rules checking, say the business rules have already been checked because the records already exist in the database, then you can just copy them and use the raw ADO.NET.  However, you loose the effectiveness of the business objects if you need the rules checking, and you also have to hand code any database structure changes each time the database itself changes.  So, if you need the rules checking, then you will probably have to keep the business objects logic.

You might also look into SQL Server bulk updates... you can execute several inserts all at once with a bulk update.

And if the structures are the same between the business objects (which they probably aren't... since you mentioned different databases), then you'll most likely want to copy the data between the rows by copying the item array within the DataRow.

Robin J Giltner
Robin J Giltner
StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)
Group: Forum Members
Posts: 105, Visits: 650
Thanks Ben, thats what I was afraid of.  One more quick question, if I create a StoredProcedure to do the Insert, do the BO rules still get checked?

Thanks

Robin Giltner

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yes, the only difference is that the INSERT is done with a stored procedure rather than with the dynamic SQL built by the DataLayer.
Robin J Giltner
Robin J Giltner
StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)
Group: Forum Members
Posts: 105, Visits: 650
Gotcha.

Thanks.

Robin Giltner.

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