I have created a MVC application where my forms in the views are using a DBML as a model. But how do i validate when im not really using a traditional model file?
1 Answer
Try the method suggested in this post of using the metadatatype attribute.
4 Comments
JavaCake
That looks interesting, his problem is exactly as mine. What i dont understand is how its fully implemented. And how it knows about the properties/variables in my dbml file.
steve v
The DBML entities are declared as partial. In that solution he supplements the entity declaration with another partial solely for the purpose of adding the metadatatype to instruct MVC to use the secondary type for validations/data annotations. That, at least, is my understanding.
JavaCake
that makes good sense, but i dont understand the metadata stuff.
steve v
It is instructing MVC that the specified class contains metadata for the class, which could include validation details, etc. See the remarks in the msdn article I linked, or this article with a similar example: msdn.microsoft.com/en-us/library/ee256141.aspx