[英]How can I have a required and nonSerialized attribute in my model
In my Model I have things like that : 在我的模型中,我有类似的东西:
[...]
public string PasswordConfirm { get; set; }
public string Captcha { get; set; }
[...]
I would like that these two attributes are required but not serializable 我希望这两个属性是必需的但不能序列化
I tried tu use [required] and [nonSerialized] annontations but without success. 我尝试使用[必需]和[nonSerialized]标注,但未成功。 I already saw this post
我已经看过这篇文章
But I don't know how to do what I want. 但是我不知道该怎么做。 It will be helpful for NonObtrusive-Validation, i want these field complete but i don't want to serialized them.
这将对NonObtrusive-Validation有所帮助,我希望这些字段完整,但我不想序列化它们。
I found a solution to my answer. 我找到了答案的解决方案。
I can use the annotation [notMapped] which is compatible with [required], [compare] ... 我可以使用与[必需],[比较]兼容的注释[notMapped] ...
I also use this :context.Configuration.ValidateOnSaveEnabled = false; 我也用这个:context.Configuration.ValidateOnSaveEnabled = false; where I filled my base because i got a problem with validation here.
我在这里填补了我的基地,因为我在这里遇到了验证问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.