Which is better in performance?

2019-09-11 14:12发布

问题:

I have 1000000 data which has some relation or can be group in to 3 groups. I will be have random update and add into these data. Also I may need to search many time with some property value.

This is the class structure

public struct DataGridViewRowInfo
{
   public string Id { get; set; }
   public int CollegeId { get; set; }
   public int RowID;
   public int DepartementId ;
   public string SpecialString { get; set; }       
}

I have following 3 idea to keep it. I would like to know which could be better.

  1. Keep as a single list of above object
  2. In a hierarchical structure
public class CollegeInfo
{
    public int CollegeId { get; set; }
    public Dictionary<int, DepartementInfo> DepartementInfo { get; set; }
}

public class DepartementInfo
{
   public int CollegeId { get; set; }
   public int DepartementId { get; set; }
   public Dictionary<int, DataGridViewRowInfo> DataGridViewRowsInfo { get; set;      }
}

 public struct DataGridViewRowInfo
 {
   public string Id { get; set; }
   public int CollegeId { get; set; }
   public int RowID;
   public int DepartementId ;
   public string SpecialString { get; set; }        
}

or 3. keep data in a file and operate on a small group of data.

标签: c# oop