Print Page | Close Window

Verification attributes on generated properties

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1899
Printed Date: 28-Apr-2024 at 6:42am


Topic: Verification attributes on generated properties
Posted By: JST
Subject: Verification attributes on generated properties
Date Posted: 16-Jun-2010 at 7:22am
Hi,
 
I'm using IB version 5.2.6.0. Now I would like to see stringlenght verifiers on my generated properties. But then never get generated. We're talking Silverlight here. Anything I can do or check?
 
When I manually add a verifier all goes well as expected. But going through a hundred+ entities to do this for all string properties isn't making me happy.
 
Any hints, tips, suggestions.
 
Thanks
 
Johan Storteboom



Replies:
Posted By: GregD
Date Posted: 16-Jun-2010 at 12:51pm
Do you have the Generate Validation Attributes checkbox checked on the Entity Model node in the Object Mapper when you generate? Also the associated "DevForce" RadioButton selected?


Posted By: JST
Date Posted: 17-Jun-2010 at 12:42am
I do. Also unchecked, checked again, tried .net attributes, switched back to Ideablade. All to no avail.


Posted By: GregD
Date Posted: 18-Jun-2010 at 2:00pm
I just tried it with 5.2.6 - made a brand new model with a couple of tables in NorthwindIB, generated the code, and the attributed verifiers are there as they should be. At first I didn't see them because I looked at the generated code associated with the EDMX instead of the IBEDMX. But I only did that because I spend most of my time in DevForce 2010 and there's *only* an EDMX in DF2010 solutions.

I just mention that on the off-chance you're also working with DF2010 and made the same mistake. But you're probably not as bone-headed as I am. 8-)


Posted By: GregD
Date Posted: 18-Jun-2010 at 2:58pm
Also check the MaxLength attribute on the property in the CSDL. If for some reason the CSDL entities don’t have the MaxLength set for string properties, we won't generate the StringLengthVerifier.


Posted By: JST
Date Posted: 21-Jun-2010 at 1:06am
That seems indeed to be the problem. So, the logical next question is: How do I have this property autogenerated? I set one by hand, and indeed the attribute was there. So far so good. But now ...? Any inside information on this? Thanks.


Posted By: GregD
Date Posted: 21-Jun-2010 at 8:50am
The generation of that attribute in the CSDL would be up to the Entity Framework. Try generating a fresh model against the same table(s) and see if it gets generated.


Posted By: JST
Date Posted: 25-Jun-2010 at 3:17am
Right, it gets generated on new model. To bad it can't be done when doing update. Oh well, I guess this will be an hour or two renaming properties and copying the right partial files again. It'll work out. Thanks.



Print Page | Close Window