【发布时间】:2015-01-27 10:18:45
【问题描述】:
我多次记录一个类。我创建列表并创建 Stats 的对象,然后添加到我的列表中,但最近的记录被所有人复制。这是我的代码
List<Account> account = accountDao.All().Where(a => a.Role ==
Role.Distributor && a.ParentAccount.Id==1&&a.Active).ToList();
ViewBag.Accounts = account;
List<Stats> statsforRegions = new List<Stats>();
foreach (Account dist in account)
{
List<int> userIdss = new List<int>();
List<int> accountIdss = new List<int>();
Stats stt = new Stats();
stt=stats;
getUserIdsRecursive(dist, userIdss, accountIdss);
stt = calculate(stt, userIdss, accountIdss);
statsforRegions.Add(stt);
}
ViewBag.StatsForRegions = statsforRegions;
【问题讨论】:
-
请编辑您的标签,因为这是 C#,而不是 C。
-
我不明白你的问题和问题?比如“但最近的记录被所有人复制。”
-
calculate长什么样子? -
-
他是说最后创建的项目填满了整个列表(因为没有创建新项目。-见 GazTheDestoyer 的回答