Master/Detail on deep business object graph

Stimulsoft Reports.NET discussion
Post Reply
Tobias Grimm
Posts: 19
Joined: Tue Oct 23, 2007 9:16 am
Location: Germany

Master/Detail on deep business object graph

Post by Tobias Grimm »

Hello,

I have some kinda tricky business object reporting problem here. Consider these classes:

Code: Select all

public class ProductTurnover
{
    Product Product { get; }
    decimal Amount { get; }
    decimal Quantity { get; }
}

public class Product
{
    string Name { get; }
    decimal Price { get; }
    IList EnhancedArticleNumbers { get; }
}
Now let's say, I want to build a report on a list of ProductTurnovers:

Code: Select all

List data = new List();
...
report.RegData("MyReport", data);
This gives me three data sources: "MyReport", "MyReport_Product" and "MyReport_Product_EnhancedArticleNumber".

What I would like to do now, is have a Master and a Detail data band:

Code: Select all

Master: MyReport.Product.Number, MyReport.Product.Name, MyReport.Quantity, MyReport.Amount
Detail: MyReport_Product_EnhancedArticleNumber
So this should basically be a list of product turnovers, listing all EAN codes of a product after each line.

Is there a way to do this, with only two data bands? If I setup a master and detail data band for "MyReport" and "MyReport_Product_EnhancedArticleNumber", then the resulting report is empty. If I use three data bands ("MyReport" -> "MyReport_Product" -> "MyReport_Product_EnhancedArticleNumber") then it works.
s/MikeT/Tobias/
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Master/Detail on deep business object graph

Post by Edward »

The reason for such a behavior is very simple:

Just imagine a structure of your business object:

An instance of ProductTurnover contains an item of Products and the last one contains the Enchanced_ArticleNumber as well. So 3 Databands are required always with a properly set relations between them.

But you can make a little trick. Just set the height of the first databand in 0. Also maybe you need to set a Filter for the DataBand as well, to show only records required. Using filter you can see here:

http://www.stimulsoft.com/livedemos/Rep ... ilter.html

Thank you.
Tobias Grimm
Posts: 19
Joined: Tue Oct 23, 2007 9:16 am
Location: Germany

Master/Detail on deep business object graph

Post by Tobias Grimm »

From a users point of view it doesn't make sense to use 3 Databands, when there are only two lists:

root -> 1:n -> ProductTurnover -> 1:1 -> Product -> 1:n -> EnhancedArticleNumber

I played around a little bit more with Reports.Net today and figured out, that I can do what I want this way:

1. Keep "MyReport" as it is
2. Completely drop "MyReport_Product" - It's redundant
3. Modify the relation in "MyReport_Product_EnhancedArticleNumber" to use "MyReport" as the parent data source instead of "MyReport_Product".

Is this a valid approach or is it just a happy coincidence, that this works with my tiny sample? I think the Reason that this works is, that ProductTurnover._ID == Product._ID (because it's a 1:1 relation).
s/MikeT/Tobias/
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Master/Detail on deep business object graph

Post by Edward »

Yes, may be it is the reason. But we do not recommend to change relations, which were registered with the RegData() method automatically. But adding of the new relations is ok and it is a good idea to add a new relation which is required, even if this relation connects datasources from different Connections (!). Just set Report.CacheAllData in true and it is up to you to add any relations possible in the Dictionary!

If something is still unclear, please feel free to send your test application to support[at]stimulsoft.com for review.

Thank you.
Tobias Grimm
Posts: 19
Joined: Tue Oct 23, 2007 9:16 am
Location: Germany

Master/Detail on deep business object graph

Post by Tobias Grimm »

Thanks for your help!
s/MikeT/Tobias/
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Master/Detail on deep business object graph

Post by Edward »

You are welcome.

Please let us know if any help is required.

Thank you.
Post Reply