VB Templates and StringRequired Validation

VB Templates and StringRequired Validation

Old forum URL: forums.lhotka.net/forums/t/1278.aspx


mikeclimbs posted on Wednesday, September 20, 2006

When generating an object based on a Table,  if a column is set to AllowNulls=False.  The template adds the StringRequired Validation rule for the field.

Currently I need to comment out the validation because of this.

I'm using AllowNulls=False and a default value of '' t avoid the issues of having null or blank in a database.

Am I using them incorrectly or is it case of more users want it the current way. 

Thanks

Mike

JoeFallon1 replied on Wednesday, September 20, 2006

FWIW,

In my version of the Codesmith templates I use code like this to test to see if I should add the StringRequired rule. I also initialize my String variables to "" but the only columns I care about that must have non-blank entries are those shown below.

 If variableType = "String" AndAlso col.AllowDBNull = False AndAlso _
      (col.IsUnique OrElse col.IsPrimaryKeyMember OrElse col.IsForeignKeyMember) Then
  

Joe

Copyright (c) Marimer LLC