Monday, February 16, 2015

asp.net access values from dictionary

IDictionary<string, object> keyValueCollection //- Dictionary variable

KeyValuePair<string, object> escalateres;


         escalateres = keyValueCollection.Where(x => x.Key.ToLower().Trim() == "escalateres" &&
                   null != x.Value && x.Value.ToString() != "All").FirstOrDefault(); //access values of key "escalateres"

 List<object> lstEscalatersDetails = null; //define list variable

  lstEscalatersDetails = escalateres.Value as List<object>;

  foreach (object lstEscalatersDetail in lstEscalatersDetails)
                {
                    IDictionary<string, object> keyValueCollectionHelpDeskEcalatorTime = new Dictionary<string, object>();
                 
                    keyValueCollectionHelpDeskEcalator = lstEscalatersDetail as IDictionary<string, object>;

                    FormatEscalateTime = Convert.ToString(keyValueCollectionHelpDeskEcalator["Hrs"]) + ":" + Convert.ToString(keyValueCollectionHelpDeskEcalator["Mins"]);

                    KeyValuePair<string, object> EscalateTime = new KeyValuePair<string, object>("EscalateTime", FormatEscalateTime);

                    keyValueCollectionHelpDeskEcalatorTime.Add(EscalateTime);
                    keyValueCollectionHelpDeskEcalatorTime.Add("HelpDeskSLAId", id);
                    Save(keyValueCollectionHelpDeskEcalatorTime, "HelpDeskEscalators");

                }

No comments:

Post a Comment