Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public class DashInfo
{
public int Gid { get; set; }
public string Group { get; set; }
public string Region { get; set; }
public int Duration { get; set; }
}

private void OnLoadDashBoardDataCompleted(LoadOperation<DashboardJson> loadOperation)
{
foreach (DashboardJson dashjson in loadOperation.Entities)
{
if (dashjson.groups.ElementAt(0).Cells.ElementAt(0) != null)
{
foreach (var region in loadOperation.Entities)
{
foreach (var group in region.groups)
{
List<DashInfo> dashinfos = new List<DashInfo>();
{		
new DashInfo { Gid = group.gid, Group = group.Name, Region = group.Region, Duration = group.AvgInf };
}
}
}
}
}
}


This method is true or false?
If false means pls help me.. How to add Gid,Name,Region, and Duartion to list..
Posted

Make Some Change like

C#
private void OnLoadDashBoardDataCompleted(LoadOperation<dashboardjson> loadOperation)
{
List<dashinfo> dashinfos = new List<dashinfo>();
foreach (DashboardJson dashjson in loadOperation.Entities)
{
if (dashjson.groups.ElementAt(0).Cells.ElementAt(0) != null)
{
foreach (var region in loadOperation.Entities)
{
foreach (var group in region.groups)
{

{		
dashinfos.add(new DashInfo { Gid = group.gid, Group = group.Name, Region = group.Region, Duration = group.AvgInf });
}
}
}
}
}
}
 
Share this answer
 
v2
Comments
Rnshanmugavadivel 13-Mar-15 4:49am    
Thank you Verymuch... It's working fine
You are creating a new list each time you want to add a new item. Furthermore you are not doing anything with the list after that. I guess you want to fill the list and then return it form the method:
C#
private List<dashinfo> OnLoadDashBoardDataCompleted(LoadOperation<dashboardjson> loadOperation)
{
    List<dashinfo> dashinfos = new List<dashinfo>(); // create the list once
    
    foreach (DashboardJson dashjson in loadOperation.Entities)
    {
        if (dashjson.groups.ElementAt(0).Cells.ElementAt(0) != null)
        {
            foreach (var region in loadOperation.Entities)
            {
                foreach (var group in region.groups)
                {
                    // add items to the list
                    dashinfos.Add(new DashInfo { Gid = group.gid, Group = group.Name, Region = group.Region, Duration = group.AvgInf });
                    }
                }
            }
        }
    }

    return dashinfos; // return the created list to the caller
}
 
Share this answer
 
v2
Comments
Rnshanmugavadivel 13-Mar-15 4:49am    
Thank you Very much... It's working fine..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900