tags:

views:

915

answers:

3

Has anyone been able to use a SubSonic generated collection as a "business object datasource" with Microsoft report (rdlc)? I have generated the SubSonic class code but for some reason the report datasource window is not seeing the class as a potential object collection datasource.

Is there something I need to do for this to work?

Thanks in advance...vsdotnetguy

A: 

I have loaded Reporting Service reports from business objects before (loaded via NHibernate -- which isn't exact but close enough for argument sake).

Couple of key points: 1. return your objects in List, even if you are only returning one object. 2. You want FLAT business objects. You might have to go thru a DTO transformation to get that. By flat, I mean the most complex property you can have in a business object is a string and a number (int, decimal, double). If you are expecting to grab a value like this: myObject.Customer.Name, forget it. Create a CustomerName property. 3. If you need data from multiple places try to break up your reports into subreports. You key off of the datasource key to figure out what data to return to the report.

I'll add more as I remember, it has been a few months since I've done this.

Chris Brandsma
A: 

Yes I've done it, you should only need to make sure the project containing your reports references your SubSonic project (obviously :).

Sometimes I've also found that Visual Studio can get a little borked and require a restart before repopulating the datasource window with SubSonic generated objects.

Adam
A: 

Thx Chris and Adam,

Here is the answer I found.

In my case I wanted to dynamically set the main and subreport datasources at run time using the SubSonic object collections. However, I also wanted to design the report layout using drag and drop of the datasource columns.

But I was unable to design the report using drag&drop because none of my SubSonic collections were showing up in the Website Data Sources.

However, later while I was doing some control binding using the ObjectDataSource control, I noticed that NOW my SubSonic collections were showing up in the Website DataSources window and I could drag and drop the report layout.

So if you are dynamically setting the report datasources at run time and ARE NOT using the ObjectDataSource control already in your project, you MUST add a dummy ObjectDataSource control to one of your aspx pages. This will then make the business object datasources show up in the report designer.