Not able to delete ApplicationGroupMember programatically

Apr 14, 2010 at 6:16 PM

We can create an applicationGroupMember using the following code: (and that works fine)

azManApplicationGroup.CreateApplicationGroupMember(groupAzManSid, WhereDefined.Application, true);
<font size="2">

 

</font>

But, not able to DELETE the applicationGroupMember. I am using the following code...

azManApplicationGroup.Members.Remove(azManSid);

/// The below code (ContainsKey) does not work for some reason -- hence looping through as below
     //if (groupMembersDictionary.ContainsKey(groupAzManSid))
         //    azManApplicationGroup.Members.Remove(groupAzManSid);
		Dictionary groupMembersDictionary = azManApplicationGroup.Members;
                    foreach (IAzManSid azManSid in groupMembersDictionary.Keys)
                    {
                        if (azManSid.StringValue == groupAzManSid.StringValue) /// THIS WORKS--But,This does not work --> if (groupMembersDictionary.ContainsKey(groupAzManSid))
                        {
                            azManApplicationGroup.Members.Remove(azManSid);   //// THIS does NOT WORK
                            break;
                        }
                    }
                     
Coordinator
Apr 14, 2010 at 7:33 PM

Hi,

you are using the wrong method.

Remove() is useful only to remove member from Members collection but does write anything on the Storage (same behavior of DataSet.Tables.Remove()).

The right method is SqlAzManApplicationGroupMember/SqlAzManStoreGroupMemer.Delete()

Regards,

Andrea.

__________________________________
Andrea Ferendeles
NetSqlAzMan Project Coordinator
E-mail aferende@hotmail.com Web http://netsqlazman.codeplex.com