Accessing BO data Via BusinessBindingSource


Author
Message
Bruno J Rondolat
Bruno J Rondolat
StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)
Group: StrataFrame Users
Posts: 2, Visits: 188
Forgive the lack of poor code my C# skills are very limited.

Currently sharing a large BusinessBindingSource.  This allow me to load the data once and then use it on diverse forms without having to reload the data on each form.  The underlying data is mostly static so this works very well.  

Currently using the following method to share the data .

Form1

  Form2.SharedBusinessSourceProducts = _sharedBusinessSourceProducts;
  Form2.ShowDialog();

Form2

        private BusinessBindingSource _sharedBusinessSourceProducts;
        public BusinessBindingSource SharedBusinessSourceProducts
        {
            get
            {
                return _sharedBusinessSourceProducts;
            }
            set
            {
                _sharedBusinessSourceProducts = value;
            }
        }


when I access the data in form2 I use (their must be a nicer way BigGrin )

// move to correct row
_sharedBusinessSourceProducts.BusinessObject.SeekToPrimaryKey(productID);
// get column of field QtyInBundle
 int QtyInBundleidx = _sharedBusinessSourceProducts.BusinessObject.CurrentRow.Table.Columns.IndexOf("QtyInBundle");
// get value
qtyInBundle = (Int32)_sharedBusinessSourceProducts.BusinessObject.CurrentRow.ItemArray[QtyInBundleidx];

isn't their a way I could just access the field name directly and do something like (assuming that the base BO is called BaseProductsBO)

qtyInBundle = _sharedBusinessSourceProducts.BaseProductsBO.QtyInBundle;

Basically I would like to bypass the whole getting the index of the field and just use the "typical"  access via the BO. 

I used to used the BO directly and have a shared SharedDataTableKey set but this caused some performance issues used a lot more memory and strangely not all of the memory would get returned after the form disposal. 


Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Bruno.

Try:

qtyInBundle = DirectCast(_sharedBusinessSourceProducts.BusinessObject, YourBOName).QtyInBundle;

Bruno J Rondolat
Bruno J Rondolat
StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)StrataFrame Beginner (6 reputation)
Group: StrataFrame Users
Posts: 2, Visits: 188
Thanks for your help.  You pointed me in the correct direction.  The solution in C# was to do the following.

string QtyInBundle= ((YourBOName)_sharedBusinessSourceProducts.BusinessObject).QtyInBundle;
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Glad it helped! Cool

And sorry for posting in VB.NET. I should have noticed your sample in C#.
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