This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product. Otherwise - post away!
Currently using MS's LINQ and Entity framework if you want to use the Model Validation and Auto form population functionality in MVC you have to use a funky sort of Meta_data DataAnnotations workaround to get it to work. http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx.
So if you were to add the DisplayName, Required, DataType attributes to the lightspeed model and auto-generate the Meta_data for us, I know more then a few MVC programmers who would be beating a path to your door!
I've done some investigation and it looks like we have a whole range of options. Part of this though has led to more questions that I need to ask to better understand your situation.
These *should* get you started with validation when binding with LightSpeed right away. Let me know if it doesn't.
We are interested in looking more into DataAnnotations simply because a lot of Microsoft's technologies are starting to support that however the timeframe around the possibility of integrating our validation framework and theirs is quite large due to the fact that it may not be possible and if it was it would likely be a breaking change.
I'm curious a little about why you would need the DataAnnotations support over our native support? This is not to argue that one is better than the other, but just to better understand your situation :-)
I've also done some reading about marrying the DA attributes to LightSpeed entities more easily. Ivan did some great work with our DynamicData provider (which required DA and did not support IDataErrorInfo like we use) and has a class in their which connects the two together. Unfortunately, there is no similar hook in ASP.NET MVC 2 that matches what Microsoft provided with Dynamic Data (you can read more here about the particular request being denied: http://aspnet.codeplex.com/WorkItem/View.aspx?WorkItemId=4235 ).
Now, you could still create the mapping yourself but you would have to do it for each type. Ivan suggested you may wish to look at a reflection approach where you run through all your model types and apply the descriptors required to have them expose DA validation attributes.
I hope that helps and I look forward to your thoughts.
Here is the thing, in this mvc application we are Html.DisplayFor, Html.EditorFor and the Html.ValidationFor
<%:Html.EditorFor( model => model.DateOfBirth )%>
These builtin helper functions depend on the three items I'm recommending would make a killer feature, currently the only way to use these handy shortcuts in the MVC is to do a bunch of decoration on a meta data model
[Required( ErrorMessage = "Name is Required" )]
[Required( ErrorMessage = "Date of Birth is Required" )]
What that means is that after creating a class in Lightspeed, I have to declare another class module, use the partial cabability of class declaration to tie a Metadata class to the original class, then do all my decoration
[MetadataType( typeof( Person_Metadata ) )]
internal class Person_Metadata
(as per the instructions in the link in my previous email).
So what does this give me over the built properties already in LightSpeed?
using the examples in here
[Required( ErrorMessage = "Name is Required" )]
Required is already caught during validatuion with out this extra decoration, BUT this extra decoration means I can customize the validation error that is displayed to the user (rather then the built in "property is required"),
[DisplayName( "First Names (seperated by commas)" )]
This is used with the Html.DisplayFor(model => model.PersonFirstName) function, it will automatically create an HTML label and fill it with the value I put in the attibute.
[DataType( DataType.Date )]
This one is prehaps the most useful especially with Dynamic Data templates. Again, the Lightspeed does the basic validation, (raises an error if the value is not a DateTime, but in this case, given it's a birth date, I don't really care about the "time" and so by using the DataType attribute I can go beyond the database and make it just a Date.
But even more than Date, I can define "custom" datatypes (say something like [DataType(DataType.Custom, "MySpecialKindaDataLightspeedDoesnotKnowAbout")]
Then I can create custom Dynamic Data Editor Templates for that type of Data value "MySpecialKindaDataLightspeedDoesnotKnowAbout" and without my having to do any coding at all (other then setting up these attributes) when I use the property I get my EditorTemplate I created just for that custom type.
I'm telling you anyone who works with the Dynamic Data framework (or uses MVC 2.0 to its full potential) spends way to much time creating metadata right after creating a model. If you allow us to put the metadata right INTO the model, and generate the MetaData class for us in the background as part of the tool build process, Lightspeed would be very popular! I know a few programmers who would buy it tomorrow if you had that feature added in.
As I side note, I expect that Microsoft will be adding it to EntityFrameworks modeller and may even add it to LinqToSql in the very near future. Beat them to it!
Did you get a chance to review my response, and did it make sense to you? Do you see the difference in what is currently provided and what I am requesting for ASP.NET new validation system? You might even be able to add this as part of the "partial classes" support you have added into the designer., say something lik "Add Meta_data Class Support" dialog?
If it is still not clear to you on the difference and the advantage this would have, I would really like the chance to peer-program with you the feature of meta_data and how it could add some real advantage to the Lightspeed model?