【发布时间】:2015-03-06 13:01:00
【问题描述】:
我正在使用以下代码更新表中的记录:
var usr = test.Data.user.SingleOrDefault(y => y.id == 1);
usr.name = "test";
usr.Save();
检索该行工作正常,但是当我 Save() 时,我在文件 database.cs 第 412 行中遇到 NullReferenceException,代码如下:
Constraint c = new Constraint(ConstraintType.Where, tbl.PrimaryKey.Name)
{
ParameterValue = settings[tbl.PrimaryKey.Name],
ParameterName = tbl.PrimaryKey.Name,
ConstructionFragment = tbl.PrimaryKey.Name
};
tbl.PrimaryKey 在这个地方为空,我认为这可能是问题所在。我确实在表的 id 字段上设置了主键。我还在 Visual Studio 2010 上使用来自 git repo 的最新版本。有人知道可能是什么问题吗?
编辑:
通过在此线程中使用 nosynchro 的答案修复:
希望这也能在 git repo 中得到修复。
【问题讨论】:
标签: c# .net mysql subsonic subsonic3