problem with BBS & standart .NET grid


Author
Message
hector
hector
StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)
Group: StrataFrame Users
Posts: 52, Visits: 559
Hi folks :

I have a problem with BBS & standart .NET grid.
I have 2 BO on a form ... Let Say ParentBO and ChildBO...
As the names implys one is parent and other is child.
I setup ParentRelationship and ParentBusinessObject properties of these BO's properly as i always do.
I also setup the BBS and grid as in SF Help document (Topic :Understanding the Business Binding Source (BBS) Control)
When I call ParentBO's Save I got a exception from SF's internal method PushDataToChildren.
When ı debug the problem i noticed that there is a one parent BO (ParentBO) but more then one child BO (which i never declared).
And these extra child BO's ParentRelationship was nothing...

This is first time I am using BBS...

When i worked on BBS deeply, I have also noticed that BBS ınternally, create an BO of same type for each row.

And I also noticed the problem is those Child BOs which internally added by BBS in SF.

Is this normal working logic of BBS?

Am i missing something in this picture?

Please advice ...

Kind regards...
StrataFrame Team
S
StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Nope, you're not missing anything from the picture.  The foremost limitation of the SF BusinessObjects is that they are a single object that contains many actual records.  One class and one instance contains multiple records, but the BO only talks to one record at a time.  It was designed this way to be similar to the way some older programming languages work.  However, with .NET, it's an issue because .NET expects collections for data sources, and a BO is only a single object.  So, the BO has to try to act like both a single object and a group of objects as well.  That's why we created the BBS.  It wraps a BO and turns it into a collection of instances. They all share their internal data table behind the scenes so they each behave like they are the same business object, but each is pointed to a specific row.  Since all of the children share the same internal DataTable, they don't all need to be children of the parent, just one of them does... the original one you linked up in your code.  I'll have to take a look at this and see why the ParentBusinessObject reference is getting set on all of the child objects.

FYI, this was the first item on our list of enhancements for SFv2; separate objects and collections.  We use an entity model with multiple classes instead of shoehorning all logic into one class: Entity, EntityCollection, EntityWinFormsView, EntityWpfView, EntityWebView, etc.  I'm sure you'll probably be one of our first beta users when we post it.
Edhy Rijo
E
StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Ben Chase (2/25/2013)
... I'm sure you'll probably be one of our first beta users when we post it.

Hi Ben,
Count me in, been waiting for SF2.0 for a long time<smile!!!>

Edhy Rijo

hector
hector
StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)
Group: StrataFrame Users
Posts: 52, Visits: 559
Hi Ben,

As I can see the problem is  here in this private method in ..\MicroFour StrataFrame Business\business\BusinessBindingSource.vb :

 Private Function CreateShareAndAddBusinessObject(ByVal index As Integer) As BusinessLayer
            '-- Create a new object
            Dim loReturn As BusinessLayer = CType(Activator.CreateInstance(Me._BusinessObject.GetType()), BusinessLayer)

            '-- Share the table
            Me._BusinessObject.ShareCurrentDataTable(loReturn)

            '-- Set the parent business object of the instance object
            loReturn.ParentBusinessObject = _BusinessObject.ParentBusinessObject  '->>>>>> In this line setting ParentBusinessObject increase  ChildBusinessObjects collection and when parent BO calls save method there are lot of child BO to be save and their ParentRelationship property is nothing

            '-- Add the object to the list
            Me._BusinessObjectList.Add(index, loReturn)

            '-- Return the new object
            Return loReturn
        End Function



Thanks Ben
StrataFrame Team
S
StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
OK, I think I have an idea... the ParentRelationship is generally set through the type editor on the business object component editor.  That means that the definition for the ParentRelationship gets put into the InitializeComponent() of the business object.  Any time you create a new instance of the business object type, it should already have the ParentRelationship set.  Are you setting the parent relationship a different way, such as setting it explicitly on the form?

To fix it, I can do a build for you or if you are comfortable with building the source yourself, the CreateShareAndAddBusinessObject() method needs to be changed to this:

        Private Function CreateShareAndAddBusinessObject(ByVal index As Integer) As BusinessLayer
            '-- Create a new object
            Dim loReturn As BusinessLayer = CType(Activator.CreateInstance(Me._BusinessObject.GetType()), BusinessLayer)

            '-- Share the table
            Me._BusinessObject.ShareCurrentDataTable(loReturn)

            '-- Set the parent relationship in case it was set on the business object explicitly outside of the constructor
            If loReturn.ParentRelationship Is Nothing Then
                loReturn.ParentRelationship = Me._BusinessObject.ParentRelationship
            End If

            '-- Set the parent business object of the instance object
            loReturn.ParentBusinessObject = _BusinessObject.ParentBusinessObject

            '-- Add the object to the list
            Me._BusinessObjectList.Add(index, loReturn)

            '-- Return the new object
            Return loReturn
        End Function
hector
hector
StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)
Group: StrataFrame Users
Posts: 52, Visits: 559


You are right Ben..

I did so..

I will try your sugession and let u know...

Thanks a lot
hector
hector
StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)StrataFrame Novice (118 reputation)
Group: StrataFrame Users
Posts: 52, Visits: 559


Problem is solved Ben...

Thanks a lot indeed

You are greatSmile
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