开发者

Do DataAnnotations only work with EntityFramework/Linq2Sql Classes?

开发者 https://www.devze.com 2022-12-10 13:25 出处:网络
Im using Preview 2 of the ASP .NET MVC Framework. Im trying out DataAnnotation attributes with my own NHibernate models but they dont seem to work.

Im using Preview 2 of the ASP .NET MVC Framework.

Im trying out DataAnnotation attributes with my own NHibernate models but they dont seem to work.

I was under the impression that the validation is supposed to get triggered by the model binding during a post. But even thou my model binds perfectly with wrong data supplied by me, the ModelState.IsValid still returns true.

Do DataAnnotations only work 开发者_开发问答with EntityFramework/Linq2Sql generated classes, or im just doing something wrong (which is probably the case) ?

Thanks in advance.


In a word, no. DataAnnotations work with any class.

0

精彩评论

暂无评论...
验证码 换一张
取 消