Inside the Business Object


Author
Message
John Frankewicz
John Frankewicz
StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)
Group: Forum Members
Posts: 36, Visits: 65
We have some conceptual gaps in understanding how the framework works with the Business Object.

When the Business Mapper creates a Business Object in a project we have some questions regarding creation, instantiation and access of the object.

1. Is the Business Object instantiated automatically by the framework, if so can you override the mechanism?

2. Does the Business object fill the internal datatable without having having to do it in your code?

3. If the framework creates the Business Object how does an external class access it?

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The Business Object Mapper just writes the partial class definition for the business objects, which defines the strong-typed field properties similar to a TypedDataSet. Once the business object is added to the project, it becomes just another class in the project (but a class that inherits all of the functionality of the BusinessLayer class). So, to answer your questions:



1) In a WinForms project, the business objects are not automatically instantiated by the framework (the only time this happens in the WebForms is if the business object's defined in the ApplicationBasePage are null, then we intantiate a business object and place it in the variable).



If you drop a business object on a form, you'll notice that the Windows Forms Designer adds the variable definition and the call to the constructor in the InitializeComponent() method. So, the framework does not instantiate the business objects, even if you drop them on the form. Your two options for instantiating a new business object are: a) drop one on a form, and the form will instantiate it in the InitializeComponent() call. b) create one new in code with "MyBusinessObject myBo = new MyBusinessObject()"



2) No, the business objects do not automatically fill themselves. There are methods in place to filter the already collected DataTable (such as the ChildAutoFilterOption), but you must create and call "Fill" methods to populate a business object. The ParentFormLoading event on a business object is provided for you to add a call to a "Fill" method in the proper sequence to bind the bound controls immediately after a fill.



3) If you ever want to access a business object, all of the field properties are public, and all you would need to do is obtain a reference to the business object and talk to it directly. A business object (even one that is dropped directly on a form) can be accessed as if it was just another class without any implications.



Hopefully this explains it a little better. Let me know if you need more clarification.
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