Datatable converted to Entity

Posts   
 
    
csmith12
User
Posts: 33
Joined: 08-Dec-2003
# Posted on: 02-Mar-2005 23:19:40   

Hopefully this is possible,

If I use Entity.EntityCollection.GetMultiAsDataTable() to get datatable, how can I return a possibly updated datatable to the Entity.EntityCollection?

Example:



 ' Get Customer  
    Dim Customer As New CustomerEntity(1) 

    ' Get Orders as datatable 
    Dim DT As DataTable = Customer.Wave.GetMultiAsDataTable(Nothing, Nothing, Nothing) 

    ' Some code to update the datatable 

    '  Some code to return the altered datatable to the entity


In short, I would like to get a datatable, update it, return datatable to entity, entity properties should now reflect the new values.

Is this possible?

Thanks,

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 03-Mar-2005 09:48:36   

csmith12 wrote:

Hopefully this is possible,

If I use Entity.EntityCollection.GetMultiAsDataTable() to get datatable, how can I return a possibly updated datatable to the Entity.EntityCollection?

Example:



 ' Get Customer  
    Dim Customer As New CustomerEntity(1) 

    ' Get Orders as datatable 
    Dim DT As DataTable = Customer.Wave.GetMultiAsDataTable(Nothing, Nothing, Nothing) 

    ' Some code to update the datatable 

    '  Some code to return the altered datatable to the entity


In short, I would like to get a datatable, update it, return datatable to entity, entity properties should now reflect the new values.

I think it's something like:


Dim customers As New CustomerCollection()
For Each row As DataRow In DT.Rows
    Dim newCustomer As New CustomerEntity()
    
    Dim i As Integer = 0
    For i = 0 to DT.Columns.Count-1
        newCustomer.SetNewFieldValue(i, row[i])
    Next
    
    customers.Add(newCustomer)
Next

Frans Bouma | Lead developer LLBLGen Pro