Cycling through fields and matching them

Posts   
 
    
SamRose
User
Posts: 20
Joined: 24-Jun-2008
# Posted on: 08-Jun-2009 15:17:19   

Hi all,

I have two tables, tblTest and tblTestAudit.

When I save a record in tblTest i also want to save the information into tblTestAudit

Now because I'm lazy I thought I'd be able to do this...as the table structures are the same for the same fields.


For Each _IEntityField2 As IEntityField2 In tblTestEntity.Fields
                tblTestAuditEntity.Fields(_IEntityField2.Name).CurrentValue = p_tblTestEntity.Fields(_IEntityField2.Name)
 Next

But it errors with the following

The value SD.LLBLGen.Pro.ORMSupportClasses.EntityField2 is of type 'SD.LLBLGen.Pro.ORMSupportClasses.EntityField2' while the field is of type 'System.Guid'

Is there an easier way to do this?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 08-Jun-2009 15:39:37   

Please try the following:

For Each _IEntityField2 As IEntityField2 In tblTestEntity.Fields
                tblTestAuditEntity.Fields(_IEntityField2.Name).CurrentValue = p_tblTestEntity.Fields(_IEntityField2.Name).CurrentValue
                tblTestAuditEntity.Fields(_IEntityField2.Name).IsChanged = True
                tblTestAuditEntity.IsDirty = True
Next