Csla.Data.ObjectAdapter - Strongly Types Dataset Question

Csla.Data.ObjectAdapter - Strongly Types Dataset Question

Old forum URL: forums.lhotka.net/forums/t/1732.aspx


SmeatJones posted on Thursday, November 09, 2006

This question is not strictly related to CSLA but i'm scrathing my head to solve my problem so will ask and hope.

I need to provide reports (Crystal Reports) in my application and am trying to work out how to base those reports on business objects rather than dorectly against the database.

I understnad I need to use strongly typed datasets to creat these reports (correct me if im wrong please) and can use the Csla.Data.ObjectAdapter to generate a dataset based on a BO at runtime.

How do I generate a stronglty typed dataset against my BO?  Has anyone actually done this?

I'm under a lot of pressure to produce these reports quickly and don't want to revert to running directly against the database as I believe this is definately the wrong way to go, especially when these reports require business logic to be applied and that logic already exists withint my BO's.

TIA

 

Smeat

RockfordLhotka replied on Thursday, November 09, 2006

I don't think you can define the DataSet against the objects in an automated manner. However, you can use the DataSet designer in VS to define the various DataTables, and then use the ObjectAdapter to copy the data from your objects into those DataTables. This is what I did in the first .NET book to create the Crystal Reports example.

I think, though, that in .NET 2.0 you can bind Crystal Reports directly to your objects, and that might be simpler. Unfortunately I haven't had time to try that, but I think other people on the forum have done it.

Michael Hildner replied on Thursday, November 09, 2006

Hi Smeat,

I use Crystal in the Windows Forms projects I have. You can pick your object in the Crystal wizard, and use it to design your report. At runtime, you create your object and pass it to the report.

The only things I've had a little trouble with is: 1) At design time, Crystal can't seem to find any objects that are not part of the project that the report is in. So I put my reports and bo's in the same project. 2) If you want to print something that is not a collection, like a CustomerReadOnlyRoot, you have to put it some object that can be iterated through - I can't remeber offhand the necessary interfaces. Anyway for example you can put your object in a List, and pass the List to the report.

Regards,

Mike

SmeatJones replied on Friday, November 10, 2006

Thanks for the responses

By putting the report in the same project as the BO's I was able to bind the report directly against my business object.

Nice and easy :)

Smeat

Copyright (c) Marimer LLC