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.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi guys, I'm using lightspeed in an MVC project currently, and have been using some guidance that Jeremy posted to attempt to use my model whenever possible to generate validations and input builders for my MVC views. The issue I run into is: 1) If I use the lightspeed validation attributes they are only valid on fields. Because of this, it's kind of a pain to use these on lightweight viewmodels that are just comprised of auto-properties. But this is also very convenient because I only need one system, not two for building controls and performing validation logic. 2) I can use the Data Annotations that are included in .Net and MVC, but obviously the lightspeed validations will not work using these same annotations. My goal is to consolidate validations whenever possible, so it would be great to be able to either: 1) Have the lightspeed attributes modifed to be valid on both properties and fields (and ideally include them in a separate assembly). It allows developers to pivot from these attributes more easily. 2) Allow lightspeed models to validate against the .net data annotation libraries in addition to the lightspeed attributes. The only reason I suggest #2 is that the next mvc release will have some built in opinionate input builders which would sure make it easy to leverage an existing lightspeed model to build UI elements. Right now, I'm basically building my own input builders based on the LS model attributes, but if you can leverage built in functionality, that's always nice. Thanks, Eric
|
|
|
In recent builds of the LightSpeed Dynamic Data assembly, there's a gadget called the EntityDataAnnotationProvider. This is a TypeDescriptionProvider which at runtime adds System.ComponentModel.DataAnnotations attributes to LightSpeed entity properties, based on the LightSpeed validations set up on those properties. Effectively you would only have to specify the LightSpeed validations on the entity fields, and the DataAnnotations validations on properties would come for free. This might solve your problem if you are exposing the LightSpeed model directly as part of your viewmodel. Obviously it won't help if you're building a separate viewmodel, though we might still be able to open up the code a bit to support that scenario. Although the provider is shipped under the Dynamic Data banner, I don't think there's anything that would stop you using it with any other DataAnnotations consumer. We'd be happy to work with you to help make the EntityDataAnnotationProvider work with whatever DataAnnotations-based input builders / infrastructure you're using. Does this sound useful? |
|
|
Ivan, this may be very useful. Are there any examples of how to use this or what the conversions are? I don't see anything in the documentation for the version I have: Mindscape.LightSpeed.Web.DynamicData, Version=2.2.1176.11532 I tried finding this class in reflector but didn't see it. Thanks, Eric |
|
|
It was only added recently -- build 11806, early last week. You will therefore need to update to the current nightly to try it out. There isn't any proper documentation for this but there are a few notes at http://www.mindscape.co.nz/forums/Post.aspx?ThreadID=2211&PostID=6274 -- albeit written from a Dynamic Data perspective I'm afraid. You may need to do some investigation to figure out where to hook up a TypeDescriptionProvider in other frameworks such as ASP.NET MVC. Let us know if you need help with this, or if you run across any issues or missing features that would make this more useful for your scenario. |
|
|
Cool, thanks for the tip Ivan. I will give it a shot and see what happens. Eric |
|