Using a BusinessLayer to fill a specific BO


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Can I use a generic BusinessLayer to fill a specific BO if the datatable in the BusinessLayer is filled in a way that the BO can handle?



I.e. I have a CustomersBO with these fields:



CustID

CustName



Then I instantiate a BusinessLayer and use FillDataTable with SQL like this:



Dim bo As New BusinessLayer()

bo.FillDataTable("Select CustID, CustName From Customers")




Can I then do:



CustomersBO.CopyDataFrom(bo,ClearAndFillFromCompleteTable)

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
bump...
Paul Chase
Paul Chase
Advanced StrataFrame User (592 reputation)Advanced StrataFrame User (592 reputation)Advanced StrataFrame User (592 reputation)Advanced StrataFrame User (592 reputation)Advanced StrataFrame User (592 reputation)Advanced StrataFrame User (592 reputation)Advanced StrataFrame User (592 reputation)Advanced StrataFrame User (592 reputation)Advanced StrataFrame User (592 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Greg,

I'm not sure what you a trying to do but why not something like this

Dim loTable As Data.DataTable

Fill the Data Table

loTable = MicroFour.StrataFrame.Data.DataBasics.DataSources("").GetDataTable("Select CustID, CustName From Customers", Nothing)

'Not sure if you need to clear it

CustomerBo.CurrentDataTable.Clear()

'Load the data from the Table

CustomerBo.CurrentDataTable.Load(loTable.CreateDataReader, Data.LoadOption.OverwriteChanges)


Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
That could work...and it saves the extra overhead of the BO. I'll try that. Thanks Paul!
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
Paul's option is a good one and it does save the overhead of instantiating another business object.

But, a business object can store data that does not match it's strong-typed properties, so you could really use any business object and fill it.  Just don't go trying to access those strong-typed properties that don't have a backing field, or you'll get a nice exception Wink

Using Paul's option is cleaner.

Oh, and there's also the CopyDataFrom() and MergeDataFrom() overloads that accept DataTable parameters if you won't want to use the Load method directly on the CurrentDataTable.

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Thanks for the reply Ben. It is all making sense now. I haven't done much at the data layer directly, so I appreciate Paul's comments a lot!
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