将元素添加到新创建的 DbSet 时,ID 是否总是从 1 到(元素数量)生成...或者我是否必须添加一些代码以确保发生这种情况...
真正的问题是我想拥有
public DbSet<Student> Students { get; set; }
public DbSet<StudentPointer> top100allTime { get; set; }
所以我有
public class StudentPointer
{
public int StudentPointerID { get; set; }
public int StudentID { get; set; }
public int Votes { get; set; }
}
和
public class Student
{
public int StudentPointerID { get; set; }
public int StudentID { get; set; }
public String name { get; set; }
}
所以这里发生的情况是,每次用户对学生投票时,我都会在 top100allTime 上获得 StudentPointer .. 更新它的“Vote”变量......然后假设“top100allTime”学生总是按投票顺序,我得到邻居它的 ID 是一个数字,比较它的选票,如果需要的话,在顶部列表中切换位置。
仅当 dbSet 上的 ID 始终按从 1 到(元素数)的顺序生成时才有效
这就是为什么我要问
还是有更有效的方法来制作top100List?