Hi Frans,
Why doesn't this block of code work? Note GPAgencyUsers is a table that links multiple users to multiple agencies.
GP.DAL.EntityClasses.UsersEntity user = GP.DAL.EntityClasses.UserEntity(userID);
_adapter.FetchEntity(user);
GP.DAL.EntityClasses.GpAgencyEntity agency = new GP.DAL.EntityClasses.GpAgencyEntity(agencyID);
_adapter.FetchEntity(agency);
bool success = false;
if (agency.Fields.State == SD.LLBLGen.Pro.ORMSupportClasses.EntityState.Fetched &&
user.Fields.State == SD.LLBLGen.Pro.ORMSupportClasses.EntityState.Fetched)
{
// if I don't do this, it says the collection is read-only.
// it still doesn't allow me to update the collection though.
agency.UsersCollectionViaGpAgencyUsers.IsReadOnly = false;
agency.UsersCollectionViaGpAgencyUsers.Add(user);
// This is what I tried first.. didn't update the GPAgencyUsers table
//success = _adapter.SaveEntity(agency, false, null, true);
// I think this would work, but it doesn't update the GPAgencyUser table either.
// success is always false
if (_adapter.SaveEntityCollection(agency.UsersCollectionViaGpAgencyUsers) > 0)
{
success = true;
}
}
return success;
I feel like I'm doing something stupid.