Fredrick Lackey - 472 - Mar 10, 2014

Is the nullable ability of the type (ie, int?, DateTime?, etc.) evaluated while generating tables from the POCO and, if so, is the RequiredAttribute needed for primitives?  Same for the MinimumLength attribute of the StringLengthAttribute?

paolo ponzano:

yes you can define something as public decimal? Total {get;set;} and it works… for the second part I don’t know :frowning:

Fredrick Lackey:

+paolo ponzano Thanks, however I was more curious WHY to use the Required attribute for privatives if this can be determined by the nullability of the property.  For example, in your example, we know the property is nullable and, for that reason, the generated field within the database would also be nullable.  Likewise, if the Total was not nullable, neither would the column be nullable.  This would make the Required attribute a bit obsolete… unless it is used somewhere else in SS.

Restricted Attribute is used to create a non-nullable column in the RDBMS, they can be used on reference types, e.g string / Complex types.

Fredrick Lackey:

So, is the RequiredAttribute required or used when dealing with a nullable type when the base is a value type (ie int?, double?, etc.)?

ValueTypes are not nullable, only used for ref types: