我有以下代码用于使用 Entity Framework 将数据放入关系表中:
public IList<Objective> createObjectives()
{
var objectiveNames = new[]
{
"Objective 1",
"Objective 2",
"Objective 3",
"Objective 4",
"Objective 5",
"Objective 6",
"Objective 7",
"Objective 8"
};
var objectives = objectiveNames.Select(o => new Objective
{
ObjectiveSeq = ??,
Name = o,
Description = o + " Description",
ModifiedDate = DateTime.Now
}
);
return objectives.ToList();
}
我的表名 ObjectiveSeq 中有一个新字段。如何修改我的 LINQ 以在该字段中插入从 1 开始的序列号。