﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Create a collection from business object</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 09:34:42 GMT</lastBuildDate><ttl>20</ttl><item><title>Create a collection from business object</title><link>http://forum.strataframe.net/FindPost12497.aspx</link><description>I cannot figure out how to extract a set of information from a SF BO to a collection.&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;The closest thing I could find would be to serialize and deserialize all the results into new objects, which I think would work??&amp;nbsp; But seems to complex, there should be a simpler solution.</description><pubDate>Thu, 08 Nov 2007 15:47:36 GMT</pubDate><dc:creator>Jason Seidell</dc:creator></item><item><title>RE: Create a collection from business object</title><link>http://forum.strataframe.net/FindPost12594.aspx</link><description>Sweet!!!  That is exactly what I needed!!! I knew there had to be a simpler solution.&lt;br&gt;
&lt;br&gt;
Your awesome;)</description><pubDate>Thu, 08 Nov 2007 15:47:36 GMT</pubDate><dc:creator>Jason Seidell</dc:creator></item><item><title>RE: Create a collection from business object</title><link>http://forum.strataframe.net/FindPost12516.aspx</link><description>You could place the business object within&amp;nbsp;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).&amp;nbsp; This would allow you to access the business object without worrying about the record changing each time you access a different object.&amp;nbsp;&amp;nbsp;The added benefit is that changes to these objects can still be propagated back to the database.</description><pubDate>Wed, 07 Nov 2007 09:13:29 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Create a collection from business object</title><link>http://forum.strataframe.net/FindPost12506.aspx</link><description>:DThanks 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.:D</description><pubDate>Tue, 06 Nov 2007 17:21:27 GMT</pubDate><dc:creator>Jason Seidell</dc:creator></item><item><title>RE: Create a collection from business object</title><link>http://forum.strataframe.net/FindPost12504.aspx</link><description>Hi Jason,&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;In the main form's global area&amp;nbsp;define a sorted list:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;Dim slALU As New SortedList&lt;/P&gt;&lt;P&gt;----------&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;slALU.Add(Me.BoGRS1.CurrentRowIndex, New clsALULookup(BO, CType(Me.BoGRS1.GRS_ATTType, Integer), Me.BoGRS1.GRSID.Value))&lt;/P&gt;&lt;P&gt;----------&lt;/P&gt;&lt;P&gt;The ALULookup class has the following properties. Note that one is the Data Table from the BO that is passed in:&lt;/P&gt;&lt;P&gt;Public Class clsALULookup&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' A class to provide ALU lookup data for a specific Score cell in a grading screen.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private _dv As Data.DataView = New System.Data.DataView&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private _dt As Data.DataTable = New System.Data.DataTable&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private _LongestCode As Integer = 0&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private _ShortestCode As Integer = 0&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private _DefGUID As String = ""&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private _DefCode As String = ""&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private _DefName As String = ""&lt;/P&gt;&lt;P&gt;-----------&lt;/P&gt;&lt;P&gt;Then I can extract the specific class I want from the sorted list as and when I need it and use its properties:&lt;/P&gt;&lt;P&gt;Dim clsALU As clsALULookup = CType(slALU.Item(View.FocusedRowHandle), clsALULookup)&lt;/P&gt;&lt;P&gt;If Not clsALU Is Nothing AndAlso clsALU.dv.Count &amp;gt;= 1 Then&lt;/P&gt;&lt;P&gt;&amp;nbsp;clsALU.dv.RowFilter = "PK = '" &amp;amp; CType(View.GetRowCellValue(View.FocusedRowHandle, "GRS_Score"), String) &amp;amp; "'"&lt;/P&gt;&lt;P&gt;&amp;nbsp;If CType(clsALU.dv.Item(0)("ALUReason"), Boolean) Then....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;DefaultName = clsALU.DefName .....&lt;BR&gt;-----------&lt;/P&gt;&lt;P&gt;Not strongly typed of course but, in my application, clsALU can contain different 'types' of BO.&lt;/P&gt;&lt;P&gt;Cheers, Peter</description><pubDate>Tue, 06 Nov 2007 15:51:56 GMT</pubDate><dc:creator>Peter Jones</dc:creator></item><item><title>RE: Create a collection from business object</title><link>http://forum.strataframe.net/FindPost12502.aspx</link><description>Would simply copying the data from myBO to your BOEntry suffice ?&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;P&gt;Dim loBusinessObject as new BusinessObjectType&lt;/P&gt;&lt;P&gt;loBusinessObject.CopyDataFrom(myBO, Microfour.Strataframe.Business.BusinessCloneDataType.ClearandFillfromDefaulView)&lt;/P&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;would get you a complete copy of the original business object's data as a completely different instance of the BusinessObject type.&lt;/P&gt;&lt;P&gt;I might be misunderstanding what you are needing here. (also complete guess on the ClearandFillfromDefaulValue enum, but I think that is close)&lt;/P&gt;&lt;P&gt;Robin Giltner</description><pubDate>Tue, 06 Nov 2007 14:02:58 GMT</pubDate><dc:creator>Robin J Giltner</dc:creator></item><item><title>RE: Create a collection from business object</title><link>http://forum.strataframe.net/FindPost12501.aspx</link><description>That would solve sorta half my problem. Let me elaborate.&lt;br&gt;
&lt;br&gt;
Let's says I have an object myBO, it has pulled 10 records from a database.  I want to be able to create another object BOentry and set it to an instance of the first record in myBO.  Then I may play around with myBO moving back and forth looking at other records but leaving BOentry still pointing to the first record.  So here's some imaginary code&lt;br&gt;
&lt;br&gt;
' Create a business object&lt;br&gt;
myBO = New SampleBO&lt;br&gt;
myBO.Fill10()&lt;br&gt;
&lt;br&gt;
' Now get an instance to the first record&lt;br&gt;
Dim BOentry as SampleBO&lt;br&gt;
BOentry = myBO&lt;br&gt;
&lt;br&gt;
Call FindNextEntry(myBO) ' Some other function that may navigate the myBO&lt;br&gt;
&lt;br&gt;
BOentry = ??? ' At this point I have no clue what BOentry is pointing to since BOentry is simply a shallow copy (only pointing to myBO, and not a specific instance (or row) of information within myBO)  if FindNextEntry called a MoveLast then BOentry is now pointing to the last record in myBO not the first.  The simpliest solution is to be able to create a new SampleBO object that truly contains an indepedent instance of the object.  For example, lets see it with a collection instead&lt;br&gt;
&lt;br&gt;
myColl = New Collection()&lt;br&gt;
FillCollection(myColl)  ' Add the rows to my collection&lt;br&gt;
&lt;br&gt;
' Create a new object&lt;br&gt;
Dim CollEntry as SampleObject()&lt;br&gt;
CollEntry = myColl.Item(1)&lt;br&gt;
&lt;br&gt;
Call FindNextEntry(myColl) ' Some other function that may play around with the collection&lt;br&gt;
&lt;br&gt;
CollEntry = myColl.Item(1) ' CollEntry is still pointing to the same instance of the object</description><pubDate>Tue, 06 Nov 2007 13:42:41 GMT</pubDate><dc:creator>Jason Seidell</dc:creator></item><item><title>RE: Create a collection from business object</title><link>http://forum.strataframe.net/FindPost12498.aspx</link><description>What about copying the underlying datatable out to a local datatable and manipulating that ?&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;P&gt;myBusinessObject.CurrentDataTable or myBusinessObject.CurrentView.toTable&lt;/P&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;If you need to respect any filters/sorting etc.&amp;nbsp; Then you could reference columns in the datatable with&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;P&gt;loDT.CurrentRow.Item(ColumnIndex) or loDT.CurrentRow.Item("fieldname")&lt;/P&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;You could change, update whatever you need, and if you wanted to put the data back into the database, simply fire up a CopyDataFrom method on the originating Business Object.&lt;/P&gt;&lt;P&gt;&amp;lt;sorry if the code isn't 100%, trying from memory&amp;gt;&lt;/P&gt;&lt;P&gt;Robin Giltner</description><pubDate>Tue, 06 Nov 2007 12:27:51 GMT</pubDate><dc:creator>Robin J Giltner</dc:creator></item></channel></rss>