List<ProjectCounterEntities> lstResult = new List<ProjectCounterEntities>(); List<Dictionary<ProjectStates, string>> lstProjectCount = new List<Dictionary<ProjectStates, string>>(); lstProjectCount = objClient.GetProjectCounter(); if (lstProjectCount != null) { Dictionary<ProjectStates, string> dicResult = new Dictionary<ProjectStates, string>(); dicResult = lstProjectCount.ToDictionary(dicResult); foreach (var k in dicResult) { objProCount = new ProjectCounterEntities(); objProCount.ProjectState = (ProjectStateEnumUI)k.Key; objProCount.ProjectCount = k.Value; lstResult.Add(objProCount); } return lstResult; }
I want to retrive value with respact to key , and want to map the value and key both into the DTO List<ProjectCounterEntities>, where ProjectCounterEntities is a DTO and the members of this DTO are "ProjectState" and "Count".
List<ProjectCounterEntities>
ProjectCounterEntities
The output of List<ProjectCounterEntities> will be
ProjectState Count ------------------------ projectstate1 2Projectstate2 5ProjectState3 6