I have a shipper table that has a m:n relationship with contact information. This m:n table is essentially made up of three columns:
ShipperId
ContactInfoId
ContactName
When one of my end users goes in to modify the contact information I am unable to get it to update. I have tried everything that I know of, so I hope someone can help.
So in one particular case my end user chooses contact information that is already found in the database during a CheckForDuplicateContactInfo method. So I tried this first:
duplicateContactInfo = CheckForDuplicateContactInfo(....arguments....);
shipper.ShipperContactInfo[0].ContactInfo = duplicateContactInfo;
shipper.ContactInfo[0] = duplicateContactInfo;
That didn't work, so I tried:
duplicateContactInfo = CheckForDuplicateContactInfo(....arguments....);
shipper.ShipperContactInfo.Clear();
shipper.ContactInfo.Clear();
ShipperContactInfoEntity shipperContactInfo = shipper.ShipperContactInfo.AddNew();
shipperContactInfo.ContactInfoId = duplicateContactInfo.Id;
shipperContactInfo.ContactInfo = duplicateContactInfo;
shipperContactInfo.Shipper = shipper;
shipperContactInfo.ShipperId = shipper.Id;
shipperContactInfo.ContactName = "DEFAULT";
shipper.ContactInfo[0] = duplicateContactInfo;
That didn't work either, so finally I tried:
duplicateContactInfo = CheckForDuplicateContactInfo(....arguments....);
shipper.ShipperContactInfo.DeleteMulti(); //No query executed on the db?!?!
ShipperContactInfoEntity shipperContactInfo = shipper.ShipperContactInfo.AddNew();
shipperContactInfo.ContactInfoId = duplicateContactInfo.Id;
shipperContactInfo.ContactInfo = duplicateContactInfo;
shipperContactInfo.Shipper = shipper;
shipperContactInfo.ShipperId = shipper.Id;
shipperContactInfo.ContactName = "DEFAULT";
shipper.ContactInfo[0] = duplicateContactInfo;
None of these work....I don't understand how I am supposed to update this relationship. I have literally exhausted every method I could come up with to get this relationship to update as needed. Even if the entity is marked dirty and I call save on the entity there is nothing even executed at the db level. This is quite frustrating, please show me where I am going wrong here.
Thanks,
Josh