DataBand looses connection to BusinessObject

Stimulsoft Reports.NET discussion
Post Reply
Tobias
Posts: 104
Joined: Mon Nov 24, 2008 8:44 am

DataBand looses connection to BusinessObject

Post by Tobias »

In "Design-Mode" I usually do a report.Dictionary.Clear() and report.Dictionary.BusinessObjects.Clear() to be sure to drop all unused data sources before registering the really used data sources. This works fine for normal data sources, but not for BusinessObjects. After a BusinessObjects.Clear() and then registering the data again and starting the designer, my databands are not assigned to the source anymore, even if name and alias stay the same.

See the code below:

Code: Select all

            var stiReport = new StiReport();
            stiReport.RegBusinessObject("Foo", new
            {
                Something = "Anything",
                Items = new []
                {
                    new { SomethingElse = "AnythingElese"},
                    new { SomethingElse = "AnythingElese"},
                    new { SomethingElse = "AnythingElese"},
                }
            });
            stiReport.Dictionary.SynchronizeBusinessObjects(2);
            stiReport.Design();

            stiReport.Dictionary.BusinessObjects.Clear();
            stiReport.RegBusinessObject("Foo", new
            {
                Something = "Anything",
                Items = new[]
                {
                    new { SomethingElse = "AnythingElese"},
                    new { SomethingElse = "AnythingElese"},
                    new { SomethingElse = "AnythingElese"},
                }
            });
            stiReport.Dictionary.SynchronizeBusinessObjects(2);
            stiReport.Design();
Tobias
Posts: 104
Joined: Mon Nov 24, 2008 8:44 am

Re: DataBand looses connection to BusinessObject

Post by Tobias »

As a workaround I now do it this way:

Code: Select all

           stiReport.BusinessObjectsStore.Clear();

           // RegBusinessObject() calls here

           // figure out which BO's can be deleted because they don't exist in the BusinessObjectStore
           var businessObjectsToDelete = stiReport.Dictionary.BusinessObjects.ToList()
                .Where(
                    x =>
                        !stiReport.BusinessObjectsStore.Any(
                            y => y.Name == x.Name && y.Category == x.Category && y.Alias == x.Alias))
                .ToList();

            // Now delete the old BO's
            foreach (var businessObject in businessObjectsToDelete)
            {
                stiReport.Dictionary.BusinessObjects.Remove(businessObject);
            }

            stiReport.Dictionary.SynchronizeBusinessObjects(2);

            stiReport.Design();
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: DataBand looses connection to BusinessObject

Post by Alex K. »

Hello,

After clear the report Dictionary, the business object guid is cleared for DataBand. After registration new business objects, guids is new.

Thank you.
Post Reply