Access Business Object Gloabally


Author
Message
Tim Dol
Tim Dol
StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)
Group: Forum Members
Posts: 340, Visits: 1.4K
I have created a business object to access a XML datasource. I can access no problem but I would like to create some type of global reference of the business object within the appMain so I only have to create and fill it once and use it throughout the application. 

Hopefully this makes sense. Right now I find myself having to call the fill method to create the object each time I want to access data, so I thought there may be a more efficient way of doing this.

Thanks 

Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Tim,

I just do something like this. Not sure if it is the best way to do it but it works okay for me. I have a common class that has shared property's and methods that I use throughout my application, in this instance to get the office name I would to something like this common.OfficeProfile.OFP_OfficeName

here is an example

Public NotInheritable Class Common

' Hide Constructor so class canot be instaniated

Private Sub New()

End Sub

Private Shared _OfficeProfile As New PayrollBO.BOOfficeProfile

Public Shared ReadOnly Property OfficeProfile() As PayrollBO.BOOfficeProfile

Get

'see if Biz Obj is filled

If _OfficeProfile.Count <= 0 Then

_OfficeProfile.Fill()

End If

Return _OfficeProfile

End Get

End Property


StrataFrame Team
S
StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yep, Paul's got it right.  You can create a "static" class somewhere to house your global variables.  Then, just make the variables (or properties that wrap the variables) public and shared (static) and you'll be able to access them from anywhere within the application.

And in VB, you can even import the class name like this so you can reference the variables without having to type the classname first:

Imports MyRootNamespace.MyStaticClass

Tim Dol
Tim Dol
StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)
Group: Forum Members
Posts: 340, Visits: 1.4K
Thanks Paul and Ben, this is exactly what I was looking for.
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