Update problem

Posts   
 
    
bosefus
User
Posts: 15
Joined: 19-Mar-2004
# Posted on: 17-Nov-2004 22:13:57   

I am having a problem updating with the generated code. Here is how I am performing the update which should work. The only thing I do differently that what is in the documentation is use getmulti since this is a legacy database and no primary key is defined. Any help is appreciated.

        WarheaderCollection wc = new WarheaderCollection();
        RelationCollection r = new RelationCollection();
        PredicateExpression pe = new PredicateExpression();
        pe.Add( PredicateFactory.CompareValue( WarheaderFieldIndex.Warnum, ComparisonOperator.Equal, contractIn.ContractNumber ) );
        DbUtils.CommandTimeOut = 360;

        WarheaderEntity wh = new WarheaderEntity();
        //WardetailEntity wd = new WardetailEntity();
        Transaction t = new Transaction( System.Data.IsolationLevel.Serializable, "datainsert" );

        try
        {
            if( !wc.GetMulti( pe, r ) )
            {
                throw new Exception( "Parent contract record does not exist." );
            }
            wh = wc[0];

            wh.Custfirst = contractIn.Customer.Firstname;
            t.Add( wh );
            wh.Save();
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 18-Nov-2004 11:00:34   

You have to specify the predicate for selecting the correct entity with the Save() method (there is a Save() overload which accepts an update restriction)

Frans Bouma | Lead developer LLBLGen Pro