-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to obtain a DataTable from NHibernate
PostPosted: Thu May 19, 2005 4:32 am 
Newbie

Joined: Wed May 18, 2005 8:56 am
Posts: 5
Location: tibro, sweden
Is it possible to get the data into a datatable instead of a ilist?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 10:03 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
NHibernate has nothing to do with Dataset (hence DataTable).
If you want a DataTable, then you need to convert the entities returned by NHibernate to this DataTable.

Why do you need DataTable ?
I ask this because, most of the time, it is possible to avoid it.

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 2:21 pm 
Newbie

Joined: Wed May 18, 2005 8:56 am
Posts: 5
Location: tibro, sweden
I use a component that only takes a datatable,dataset or a dataview as datasource.

Is there any simple way to convert the ilist to a datatable or do i have to loop all the posts and insert them into the datatable?

I create the datatable like this
Code:
Dim dt As New DataTable
        Dim dtc, dtc1, dtc2, dtc3, dtc4, dtc5, dtc6 As DataColumn
        dtc = New DataColumn
        dtc1 = New DataColumn
        dtc2 = New DataColumn
        dtc3 = New DataColumn
        dtc4 = New DataColumn
        dtc5 = New DataColumn
        dtc6 = New DataColumn
        With dtc
            .ColumnName = "ID"
            .DataType = System.Type.GetType("System.Int32")
        End With
        With dtc1
            .ColumnName = "gameID"
            .DataType = System.Type.GetType("System.Int32")
        End With
        With dtc2
            .ColumnName = "teamID"
            .DataType = System.Type.GetType("System.Int32")
        End With
        With dtc3
            .ColumnName = "startTime"
            .DataType = System.Type.GetType("System.DateTime")
        End With
        With dtc4
            .ColumnName = "endTime"
            .DataType = System.Type.GetType("System.DateTime")
        End With
        With dtc5
            .ColumnName = "eventDate"
            .DataType = System.Type.GetType("System.DateTime")
        End With
        With dtc6
            .ColumnName = "Task"
            .DataType = System.Type.GetType("System.String")
        End With

        With dt
            .Columns.Add(dtc)
            .Columns.Add(dtc1)
            .Columns.Add(dtc2)
            .Columns.Add(dtc3)
            .Columns.Add(dtc4)
            .Columns.Add(dtc5)
            .Columns.Add(dtc6)
        End With
        Dim dtr As DataRow
        For Each e As tik2005.schedule1 In scheduleDB.getSchedule(startDate, endDate)
            dtr = dt.NewRow
            dtr("ID") = e.ID
            dtr("gameID") = e.gameID
            dtr("teamID") = e.teamID
            dtr("startTime") = e.startTime
            dtr("endTime") = e.endTime
            dtr("eventDate") = e.eventDate
            dtr("Task") = e.Task
            dt.Rows.Add(dtr)
        Next


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.