Page 1 of 1

DataBand looses connection to BusinessObject

Posted: Fri Jun 17, 2016 10:52 am
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();

Re: DataBand looses connection to BusinessObject

Posted: Fri Jun 17, 2016 11:30 am
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();

Re: DataBand looses connection to BusinessObject

Posted: Fri Jun 17, 2016 12:56 pm
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.