Adding an entity

Posts   
 
    
Posts: 30
Joined: 17-Sep-2006
# Posted on: 18-Sep-2007 15:14:41   

I'm missing something blindingly obvious here...

IEntity2 e = entityMappingFactory.Create(); e.PrimaryKeyFields[0].CurrentValue = tagEntity.TagId; e.PrimaryKeyFields[1].CurrentValue = objectId; //e.FlagMeAsChanged(); // also tried this a.SaveEntity(e); // where a is a DataAccessAdapter

I'm having to access the primary keys like this as the logic applies to more than one "mapping" type table. SaveEntity doesn't throw an exception, but doesn't execute any query.

What haev I forgotten? smile

Thanks for your help!

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 19-Sep-2007 01:03:39   

try this:

IEntity2 e = entityMappingFactory.Create(); e.SetNewFieldValue(e.PrimaryKeyFields[0].FieldIndex, tagEntity.TagId); e.SetNewFieldValue(e.PrimaryKeyFields[1].FieldIndex, objectId); a.SaveEntity(e);

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 19-Sep-2007 12:18:07   

Also, the PK fields are linked in a target-per-entity scenario, so you just have to set one to set all of them.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 30
Joined: 17-Sep-2006
# Posted on: 19-Sep-2007 13:45:23   

Great, thanks guys!