readonly Identical column

Posts   
 
    
mohamed avatar
mohamed
User
Posts: 136
Joined: 10-Mar-2008
# Posted on: 24-Jun-2009 13:59:26   

Greetings,

I have simple table called Country for example.

this table include 2 columns: ID is identical, CountryName.

when fetching a record from database and copy this record in a new entity it throw exception that ID is read only

how to get over read only problem ??

really i need to copy add data in new entity


public static void CopyEntity<T>(T source, T destination) where T : IEntity2
        {
            foreach (EntityField2 item in source.Fields)
                destination.Fields[item.Name].CurrentValue = item.CurrentValue;
        }

Using Adapter mode LLBL 2.6 Database SQL2008

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 24-Jun-2009 14:15:51   

You can set the identity field's value using entity.Fields[index].ForcedCurrentValueWrite(). eg.

destination.Fields[item.Name].ForcedCurrentValueWrite(item.CurrentValue);
mohamed avatar
mohamed
User
Posts: 136
Joined: 10-Mar-2008
# Posted on: 24-Jun-2009 14:30:58   

Thanks Walaa.. Really appreciate that...

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 24-Jun-2009 14:44:34   

You are mostly welcomed. simple_smile