-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: iList to DataSet or DataTable (Crystal Reportes usage)
PostPosted: Mon Aug 22, 2005 1:18 pm 
Newbie

Joined: Sat Aug 20, 2005 10:39 am
Posts: 12
Location: Brazil
Hi,

I use the Crystal Reports to generate reports. It only works with DataSet. Exists some form to convert DataSet for iList?


Thanks,

[]s


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 22, 2005 1:34 pm 
Beginner
Beginner

Joined: Thu May 12, 2005 2:14 am
Posts: 33
Location: Sweden, Sk
Not a answer.. sorry for that.. But when NH runs a report query, wouldnt it be nice to return a (System.Data) datatable instead of a array of objects.

In most cases I have to convert it to a DT and then display it..


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 22, 2005 4:56 pm 
Newbie

Joined: Sat Aug 20, 2005 10:39 am
Posts: 12
Location: Brazil
Hi friend,

You it would have some example of as to make this conversion?

I tried to convert directly but it gave an error of type of invalid conversion. :(

I thank its aid very.

[]s


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 7:51 am 
Regular
Regular

Joined: Mon Jul 18, 2005 4:10 am
Posts: 92
Location: Poland
Hi,
I'm using Reflection for this task : object.GetType.GetProperties() gives me array of PropertyInfo objects, then [propertyinfo instance].PropertyType gives the data types, [propertyinfo instance].GetValue(....) can read object values - with such info make two simple loops - first for creating DataTable structure, second - to put data from your objects into datatable.

Something like this (vb code, should be no problem with conversion to c#)
Code:
dim dt as new DataTable
dim pis as PropertyInfo()=myObjectArray(0).GetType.GetProperties()
For Each pi As PropertyInfo In pis
   Dim name As String = pi.Name
     Select Case pi.PropertyType.Name
        Case "Int32", "String", .....
           dt.Columns.Add(name, pi.PropertyType)
     End Select
Next

for each obj as myObjectType in myObjectArray
  For Each pi As PropertyInfo In pis
     Dim name As String = pi.Name
        Select Case pi.PropertyType.Name
            Case "Int32", "String", .....
               dim dr as DataRow=dt.NewRow
               dr(name)=pi.GetValue(obj, Nothing)
        End Select
   Next
   dt.rows.add(dr)
next

_________________
michal


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 21, 2005 12:18 pm 
shouldn't it be sufficient ?

IList lst = session.Find(query);

DataGrid1.DataSource = lst;
DataGrid1.DataBind();
DataSet1==CType(DataGrid1.DataSource,DataSet)


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.