How to use a BO to generically retrieve data


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
This sample shows how to retrieve any arbitrary data (i.e. could be completely unrelated to the BO being used) using a BusinessObject.



The FillDataTable method of the base BusinessLayer class can execute any arbitrary SQL (or a SqlCommand object) and the BO will be loaded with the retrieved data, into a ADO.NET DataTable, referenced via the CurrentDataTable property of the BO. When answering a question on the forum (http://forum.strataframe.net/FindPost26703.aspx) I incorrectly thought that using a generic BusinessLayer object would do the trick. Unfortunately, the BusinessLayer is not ready for use, as it requires server properties to be overloaded. This sample shows how to use any mapped BO (thus all the properties are overridden) to get any data needed from the any table required.



This method can be used with EnterpriseServer. For applications that use direct connections to a database, they normal ADO.NET methods can be used when necessary. However, when using ES, this type of strategy will not work. This can be used when needed to get the job done.



The sample will prompt you to connect to a database via the normal SF connection wizard. The sample SQL provided uses the StrataFrameSample database and is designed to query the Customers table. Clicking on the Set Enterprise Connection button will allow you to connect to an ES server to test how it works against an ES server. The GenericBO is mapped to the Customers table form the StrataFrameSample database. However, you can use it to query completely different databases.



This also shows how to setup a listview to display the results, including setting the populations settings and configuring the columns based on the current data table in the BO.



Comments are always welcome. Enjoy! BigGrin
Attachments
GenericBOSample.zip (349 views, 29.00 KB)
Replies
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Luiz,



I'm using a newer version of the Framework. This works on older versions too, you'll just need to make sure the references to the SF assemblies are correct (remove and re-add them) and you'll need to use the BO mapper to redo the GenericBO. Just open the BO Mapper, configure the project to use the StrataFrameSample db and point the GenericBO at the Customers table (actually, any database and any table will work), then rebuild it. Version 1.7 changed how the field descriptors worked (I think that was when it was), so all BOs had to be rebuilt via the BO Mapper. I'm using one or two version from latest, but it is 1.7 something. BigGrin



Charles,



Glad you like it! Cool
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Thanks for the sample, Greg! Good job. Wink
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