Thanks alot Jason.

On Jan 28, 6:02 pm, Jason Meckley <[email protected]> wrote:
> I have also used NH with Crystal passing an IEnumerable to the crystal
> report. if the list is empty though Crystal freaks out. Not liking
> DataTables all that much I created an simple extension method to
> convert an IEnumerabl<> to a datatable. This way I only work with the
> datatable when passing it to the report.
> public static DataTable ConvertToTable(this IEnumerable<T> items)
> {
>      var table = new DataTable();
>      var type = typeof(T);
>      var properties = type.GetProperties();
>
>      foreach(var property in properties)
>      {
>           table.Columns.Add(property.Name, property.Type)
>      }
>
>     foreach(var item in items)
>     {
>            var row = properties
>                   .Select(p=>p.GetValue(item, null))
>                   .ToArray();
>            table.Rows.Add(row);
>     }
>     return table;
>
> }
>
> when I need to generate a report I can query via NH. map the entities
> to a report specific view and convert the data to table.
> var data = session
>            .CreateCriteria<X>()
>            .Future<X>()
>            .Select(x => mapper.Map<X, Y>(x)
>            .ConvertToTable();
> using(var report = new MyReport())
> {
>      report.SetDataSource(data);
>      report.Export(...);
>
> }
>
> On Jan 28, 1:15 am, wanyaland <[email protected]> wrote:
>
> > Thanx Paulo. What I did was to pass my objects to a datatable and bind
> > the table to the report.Its working at least considering crystal
> > reports work with datasets/datatables
>
> > On Jan 11, 10:23 pm, Paulo Quicoli <[email protected]> wrote:
>
> > > Hi,
>
> > > here we pass list of object to a crystal reports report...
>
> > > 2010/1/11 Harold Wanyama <[email protected]>:
>
> > > > ---------- Forwarded message ----------
> > > > From: Harold Wanyama <[email protected]>
> > > > Date: Mon, Jan 11, 2010 at 5:15 PM
> > > > Subject: Report generation with Nhibernate
> > > > To: [email protected]
>
> > > > Hi all, Iam a newbie in Nhibernate and so far so good as I work grasp 
> > > > the
> > > > nhibernate ideas and workarounds on it. Iam working on a project and am 
> > > > at
> > > > the stage of creating reports. How can I do this? Any simple example 
> > > > will
> > > > do. I am able to fetch data from the db and am using Hql for that.
> > > > Harold
>
> > > > --
> > > > You received this message because you are subscribed to the Google 
> > > > Groups
> > > > "nhusers" group.
> > > > To post to this group, send email to [email protected].
> > > > To unsubscribe from this group, send email to
> > > > [email protected].
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=en.
>
> > > --
> > > Paulo R. Quicoli
>
> > > Editor Técnico - ClubeDelphi Magazine - DevMedia

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to