我的ORM(LightSpeed)为动物表生成此名称,其中包含名称和年龄。使用MVC3和剃刀使用Lightspeed MVC3验证
[Serializable]
[System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
[System.ComponentModel.DataObject]
[Table(IdColumnName="AnimalID", IdentityMethod=IdentityMethod.IdentityColumn)]
public partial class Animal : Entity<int>
{
[ValidatePresence]
[ValidateLength(0, 50)]
private string _name;
[ValidateComparison(ComparisonOperator.GreaterThan, 0)]
private int _age;
public const string NameField = "Name";
public const string AgeField = "Age";
[System.Diagnostics.DebuggerNonUserCode]
[Required] // ****I put this in manually to get Name required working
public string Name
{
get { return Get(ref _name, "Name"); }
set { Set(ref _name, value, "Name"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public int Age
{
get { return Get(ref _age, "Age"); }
set { Set(ref _age, value, "Age"); }
}
随着[必需]属性补充说:
由于没有[必需]属性补充:(注意光速奇怪验证渲染)
名称填入:
在上面的图像 - 顶部的验证是光速(投入的ValidationSummary),并在侧是MVC3(投入ValidationMessageFor)仅
正在使用服务器端验证当前。
问题:我如何在MVC3中正常使用LightSpeed验证?
我认为这是一些在这个领域http://www.mindscapehq.com/staff/jeremy/index.php/2009/03/aspnet-mvc-part4/
对于服务器端验证 - 您将要使用从光速验证更准确,而不是借力DefaultModelBinder行为发出错误的自定义模型粘合剂。看看直接使用或从社区代码库适应EntityModelBinder MVC的
http://www.mindscapehq.com/forums/Thread.aspx?PostID=12051