The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Updating part of primary key in many to many table.

Last post 07-02-2007, 9:22 AM by Scott.Schecter. 1 replies.
Sort Posts: Previous Next
  •  07-02-2007, 9:14 AM 3488

    Updating part of primary key in many to many table.

    I am writing a move method.  My many to many table has more data then the two foreign keys so I thought I would update one of the foreign keys to move the record.  The two foreign keys combine to make the only primary key for the table.  I get a where clause error when trying to do this.  I am using EntitySpaces 2007 with SQL Server 2005.

    My code:

    Code:
    public void MoveSafetyFeatureTo(int oldSafetyFeatureId, int newSafetyFeatureId)
    {
    	VehicleSafetyFeatures feature = new VehicleSafetyFeatures();
    	feature.LoadByPrimaryKey(this.Id.Value, oldSafetyFeatureId);
    	feature.SafetyFeatureId = newSafetyFeatureId;
    	feature.Save();
    }

     

    Update sql from profiler:

    Code:
    exec sp_executesql N'SET NOCOUNT OFF UPDATE [VehicleSafetyFeatures] SET  WHERE ([VehicleId] = @VehicleId AND 
    [SafetyFeatureId] = @SafetyFeatureId)',N'@VehicleId int,@SafetyFeatureId 
    int',@VehicleId=5485,@SafetyFeatureId=71

     

    I guess the primary key is not updated at all? Is this a problem or should I just move to a clone, delete, and add method of moving the record?

  •  07-02-2007, 9:22 AM 3490 in reply to 3488

    Re: Updating part of primary key in many to many table.

    This has been covered several times, EntitySpaces does not support updating of primary keys by design.

    Regards,

    Scott Schecter
    EntitySpaces | My Site
View as RSS news feed in XML