views:

25

answers:

0

I'm trying to update a record using the Entity model (3.5) when I get this error. I have no such parameter named "record".

In walking through the code, a single entity is found, The four Entity keys are filled correctly("EntitySet=WOTimeRecording;WorkOrderNbr=69229;UserQID=Qlab64;WeekIdentifier=2010-Week14;TimeIdentifier=5") , and the update status is "Modified".

The save changes goes through the entity key fields and only "Gets" values for one of the Entity Keys(WorkOrderNbr) and the rest are null or 0 if integer. I think this is what is causing the Null Key error I'm getting but Why? It seems that the Entity attached to the context has Keys and values filled yet the saveChanges() method doesn't find them on the Get method. How do I get the save logic to identify the entity keys and process the update?

Here is the simplified code:

    List<WOTimeRecording> results;

    //Get Work Order Time records 
    using (ADMTimeTrackingEntities WOcontextUpdate = new ADMTimeTrackingEntities())
    {
        IQueryable<WOTimeRecording> WOTR2 =
                from s in WOcontextUpdate.WOTimeRecording
                where s.UserQID == QID && s.WeekIdentifier == WeekID &&    
                     s.WorkOrderNbr== WorkOrderNbr
                select s;
         results = WOTR2.ToList();

        //execute query
        foreach (WOTimeRecording WOTR in results) 
        {

            .... update WOTR values as necessary,  --Should only be one Entity 

         } //loop

         //persist changes

           EntityKey WOTRKey = WOTR.EntityKey;   //verified there are values
           EntityState WOTRState = WOTR.EntityState; //verified value is Modify

           WOcontextUpdate.SaveChanges();

     } //using