Business objects with child collections

Stimulsoft Reports.NET discussion
Post Reply
naasking
Posts: 6
Joined: Fri Jul 29, 2016 7:28 pm

Business objects with child collections

Post by naasking »

I'm demoing Stimulsoft, and I have a report generated from a business object that has a child collection, something like:

Code: Select all

public class Order
{
  public string OrderNumber {get;set;}
  public IEnumerable<Product> Products {get;set;}
}
public class Product
{
  public string Name {get;set;}
}
I want to bind a data band to to the Order.Products collection. The obvious way seems to be creating a "child of business object" data source, but my dialog in the demo editor always has the child option greyed out like this. All of the other guides are for older version of the Stimulsoft designer, so they're no help.

I even tried adding the Product as its own data source and then defining a relation between Order and Products, but the "OK" button is always greyed out no matter what I specify in this dialog (I'm not sure if the relation would do what I want anyway).

I should also note that defining a new data source just for the collection that I have to manually bind via RegBusinessObject is not acceptable. I'm already calling RegBusinessObject on the top-level object which contains the child collection, I should just be able to extract the needed data from that.

Honestly, such a simple thing shouldn't be this complicated, and the video certainly makes it seem easy, so what am I missing?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Business objects with child collections

Post by Alex K. »

Hello,

Please try to use the SynchronizeBusinessObjects() method:

Code: Select all

report.RegBusinessObject("Demo", ds);
report.Dictionary.SynchronizeBusinessObjects(2);
Thank you.
naasking
Posts: 6
Joined: Fri Jul 29, 2016 7:28 pm

Re: Business objects with child collections

Post by naasking »

I don't think you understand. I'm using the Stimulsoft designer to design a report. I can't tell the designer that I want to bind a data band to a child collection of an existing data source. There is no code involved here.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Business objects with child collections

Post by Alex K. »

Hello,

We couldn't reproduce this bug.
Please send us a simple project which reproduces the issue for analysis.

Thank you.
Attachments
Capture.PNG
Capture.PNG (43.68 KiB) Viewed 5496 times
naasking
Posts: 6
Joined: Fri Jul 29, 2016 7:28 pm

Re: Business objects with child collections

Post by naasking »

To be clear, I'm trying to update an existing report from an older version of Stimulsoft to the new version and switch it to use business objects. I can't even add a business object using the context menu, I had to add it as New Data Source > Data From Business Objects, so perhaps that's the source of the problem. How do I fix that?
test-report.png
test-report.png (53.78 KiB) Viewed 5493 times
I can see the appropriate selection in a new report, but not in existing reports. Also, when adding a child object for the new report, it doesn't let me select which column is the child. The "BOM" property of the "Bill" business object is an IEnumerable<BillOfMaterialRow>, but looking at the second attached image, it's not at all clear how this is supposed to work (and the documentation does not describe how to do this).
new-report-child.png
new-report-child.png (68.66 KiB) Viewed 5493 times
If I add the row class manually, it shows up as in the third image, but as a duplicate BOM property as in the third image. I have no idea if BOM is automatically populated from Bill.BOM or what's going on here.
child-report.png
child-report.png (68.51 KiB) Viewed 5493 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Business objects with child collections

Post by Alex K. »

Hello,

We couldn't reproduce this bug.
Please send us a simple project which reproduces the issue for analysis.

Thank you.
naasking
Posts: 6
Joined: Fri Jul 29, 2016 7:28 pm

Re: Business objects with child collections

Post by naasking »

I've sent a PM with the files.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Business objects with child collections

Post by Alex K. »

Hello,

> I can't even add a business object using the context menu, I had to add it as New Data Source > Data From Business Objects, so perhaps that's the source of the problem.

Please try to set the EngineVersion property for your report to EngineV2.

Thank you.
naasking
Posts: 6
Joined: Fri Jul 29, 2016 7:28 pm

Re: Business objects with child collections

Post by naasking »

A bit late, but that fixed the issue, thanks!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Business objects with child collections

Post by Alex K. »

Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.
Post Reply