When creating an ASP.NET MVC or a Silverlight application a good practice you can employ is the validating your data based on Data Annotation attributes. Those attributes express some requirements such as acceptable string length, mandatory fields, etc. However, in most of the cases you have to define them manually, for each property, which for large data models can take hours or even days to get it right.

Is there any way we can help you with that? It turns out that there is - many of those validations can be derived from the database schema and exposed to the front-end automatically. This is exactly what you can get out of the box with the upcoming Q2 2013 release of Telerik OpenAccess ORM. Limitations on the data for each column are read from the database and applied for your classes automatically, through a simple checkbox in your Model Settings:

Data Annotation setting

For instance, a CustomerID property could look like:

public virtual string CustomerID

This way, the client code for the property already knows that it has to provide a value for it and this value cannot be longer than 5 characters. Apart from that, the property is a key for its class and can be used as such in your data binding scenarios without hard-coding this information in the User Interface layer!

In fact, this is not the only improvement of the OpenAccess ORM code generation you will see in the new version. Stay put as we continue posting the other cool things you will be able to do with the enhanced Code Generation settings!
About the Author

Ivailo Ivanov

 is Team Lead in Telerik Data Access

Related Posts


Comments are disabled in preview mode.