How to use a BO to generically retrieve data


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (2.7K 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 (203 views, 29.00 KB)
Luiz Lima
Luiz Lima
StrataFrame Novice (80 reputation)StrataFrame Novice (80 reputation)StrataFrame Novice (80 reputation)StrataFrame Novice (80 reputation)StrataFrame Novice (80 reputation)StrataFrame Novice (80 reputation)StrataFrame Novice (80 reputation)StrataFrame Novice (80 reputation)StrataFrame Novice (80 reputation)
Group: Forum Members
Posts: 66, Visits: 724
Greg,

I´ve got some errors when compiled the project, I have version 1.6.6.0

See the screen-shot.

Error 6 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 632 46 GenericBOSample
Error 7 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 633 45 GenericBOSample
Error 8 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 634 48 GenericBOSample
Error 9 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 635 49 GenericBOSample
Error 10 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 636 47 GenericBOSample
Error 11 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 637 45 GenericBOSample
Error 12 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 638 47 GenericBOSample
Error 13 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 639 47 GenericBOSample
Error 14 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 640 43 GenericBOSample
Error 15 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 641 44 GenericBOSample
Error 16 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 642 45 GenericBOSample
Error 17 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 643 46 GenericBOSample
Error 18 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 644 44 GenericBOSample
Error 19 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 645 47 GenericBOSample
Error 20 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 646 51 GenericBOSample
Error 21 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 647 49 GenericBOSample
Error 22 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 648 53 GenericBOSample
Error 23 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 649 46 GenericBOSample
Error 24 Value of type 'GenericBOSample.GenericBO.FieldDescriptor' cannot be converted to 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 650 46 GenericBOSample
Error 25 'MicroFour.StrataFrame.Business.FieldPropertyDescriptor' has no type parameters and so cannot have type arguments. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 787 72 GenericBOSample
Error 26 function 'GetValue' cannot be declared 'Overrides' because it does not override a function in a base class. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 792 31 GenericBOSample
Error 27 'Field' is not a member of 'GenericBOSample.GenericBO.FieldDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 793 19 GenericBOSample
Error 28 sub 'SetValue' cannot be declared 'Overrides' because it does not override a sub in a base class. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 838 26 GenericBOSample
Error 29 'Field' is not a member of 'GenericBOSample.GenericBO.FieldDescriptor'. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 839 19 GenericBOSample
Error 30 property 'ComponentType' cannot be declared 'Overrides' because it does not override a property in a base class. C:\Users\Luiz\Desktop\GenericBOSample\GenericBO.Designer.vb 884 40 GenericBOSample
Error 31 Type 'Enterprise.EnterpriseDataSourceItem' is not defined. C:\Users\Luiz\Desktop\GenericBOSample\MainForm.vb 169 37 GenericBOSample


Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
By George,McGuffey, you've done it again ! BigGrin



The implications of this technique are ... wow!



Mind already rushing with how I'll use some of this in reproducing some of the highly developed querying stuff in the the fund-raising app.



Thanks for putting together this extremely clear and useful sample.



Greg McGuffey
Greg McGuffey
Strategic Support Team Member (2.7K 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 (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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