Create a collection from business object


Author
Message
Jason Seidell
Jason Seidell
StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)
Group: Forum Members
Posts: 59, Visits: 180
I cannot figure out how to extract a set of information from a SF BO to a collection.  I want seperate objects that I can pass around and change the properties of without having to be tied to one BO, and without any concern of the BO's being written back to the database, or one subroutine navigating the BO and breaking the caller sub b/c it didn't realize the recordset was changed, or having to manually reset the BO back to whatever record I was looking at before.

The closest thing I could find would be to serialize and deserialize all the results into new objects, which I think would work??  But seems to complex, there should be a simpler solution.

Jason Seidell

Programmer/Analyst

Infinedi

Replies
Peter Jones
Peter Jones
Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Jason,

This may help (or not). I recently wanted various versions on the same BO but populated differently and all versions to be available simultaneously so I built a class that contained various infor (including the BO's data table) and stuck these classes into a sorted list. In summary:

In the main form's global area define a sorted list:
   
Dim slALU As New SortedList

----------

Add a new ALULookup class to the sorted list as needed and passing in the a BO that contains the data I have at this point in time:

slALU.Add(Me.BoGRS1.CurrentRowIndex, New clsALULookup(BO, CType(Me.BoGRS1.GRS_ATTType, Integer), Me.BoGRS1.GRSID.Value))

----------

The ALULookup class has the following properties. Note that one is the Data Table from the BO that is passed in:

Public Class clsALULookup

    ' A class to provide ALU lookup data for a specific Score cell in a grading screen.

    Private _dv As Data.DataView = New System.Data.DataView
    Private _dt As Data.DataTable = New System.Data.DataTable
    Private _LongestCode As Integer = 0
    Private _ShortestCode As Integer = 0
    Private _DefGUID As String = ""
    Private _DefCode As String = ""
    Private _DefName As String = ""

-----------

Then I can extract the specific class I want from the sorted list as and when I need it and use its properties:

Dim clsALU As clsALULookup = CType(slALU.Item(View.FocusedRowHandle), clsALULookup)

If Not clsALU Is Nothing AndAlso clsALU.dv.Count >= 1 Then

 clsALU.dv.RowFilter = "PK = '" & CType(View.GetRowCellValue(View.FocusedRowHandle, "GRS_Score"), String) & "'"

 If CType(clsALU.dv.Item(0)("ALUReason"), Boolean) Then....

  DefaultName = clsALU.DefName .....
-----------

Not strongly typed of course but, in my application, clsALU can contain different 'types' of BO.

Cheers, Peter

Jason Seidell
Jason Seidell
StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)
Group: Forum Members
Posts: 59, Visits: 180
BigGrinThanks for the replies, definetly different ideas than I orginally had, but great nonetheless. I will look further into each of these ideas and see where they take me.BigGrin

Jason Seidell

Programmer/Analyst

Infinedi

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
You could place the business object within a BusinessBindingSource, which will return separate instances of the business object, each positioned to the appropriate record (the BBS acts like an IBindingListView, which is itself an IList, so you can use it like a collection).  This would allow you to access the business object without worrying about the record changing each time you access a different object.  The added benefit is that changes to these objects can still be propagated back to the database.
Jason Seidell
Jason Seidell
StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)
Group: Forum Members
Posts: 59, Visits: 180
Sweet!!! That is exactly what I needed!!! I knew there had to be a simpler solution.



Your awesomeWink

Jason Seidell

Programmer/Analyst

Infinedi

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