Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

Can we add duplicates to dictionary?

$
0
0

Hi,

I have a dictionary(Dictionary<string, Guid>) which does not allow duplicates to be added. Is there a way that we can add duplicates into it?

Here is my code snippet which fails if there is a key already in the dictionary.

Dictionary<string, Guid> dictLookupLocation = new Dictionary<string, Guid>();

                  
                   QueryExpression locationQuery = new QueryExpression("new_locations");
                   locationQuery.ColumnSet = new ColumnSet(true);
                   EntityCollection locationCollection = CRMHelper.GetCRMService().RetrieveMultiple(locationQuery);

                   foreach (Entity location in locationCollection.Entities)
                   {
                       string locationName = location.GetAttributeValue<string>("new_office");

                       if (!dictLookupLocation.ContainsKey(locationName))
                       {
                           dictLookupLocation .Add(locationName, location.Id);
                       }
                   }

Thanks for any help.


Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>