partial void OnValidate(ChangeAction action) {
if (!IsValid)
throw new ApplicationException("Rule violations prevent saving");
}
我下面这个教程:asp.net ChangeAction - 简单教程的问题
http://aspnetmvcbook.s3.amazonaws.com/aspnetmvc-nerdinner_v1.pdf
,我不能够编译上面的代码。它是在我的NerdDinner.Models.Dinner
我把它放在错误的位置?
这里的类:
public partial class Dinner {
public bool IsValid {
get { return (GetRuleViolations().Count() == 0); }
}
public IEnumerable<RuleViolation> GetRuleViolations() {
yield break;
}
partial void OnValidate(ChangeAction action) {
if (!IsValid)
throw new ApplicationException("Rule violations prevent saving");
}
}
这里的错误即时得到
Error 1 The type or namespace name 'ChangeAction' could not be found (are you missing a using directive or an assembly reference?)
请原谅初学者的问题,请让我知道如果你需要任何其他细节。即时通讯几乎可以肯定,我在这里失去了一些基本的东西任何人都可以请帮忙吗?通过必要的步骤来运行我?
我们需要看到更多的代码,哪个类包含这个方法? – CodingGorilla 2010-10-15 17:27:03
@gorilla:更新谢谢你的帮助 – 2010-10-15 17:28:33
你有没有创建.dbml文件,你确定你拼写的一切都一样吗? :) – CodingGorilla 2010-10-15 18:08:10