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
|
Running latest nightly (4.0.1544.21231)
Thanks! |
|
|
FieldInfo.IsNullable indicates if the field itself is nullable, not if the underlying database column is nullable - in the case of a string (or any other reference type) this will always return true.
|
|
|
Okay. MetaData.FieldInfo seems to expose metadata about the field<->db mapping, e.g. HumanName, IsIdentityField, IsTransient etc. So it seems surprising that IsNullable refers to the underlying type. And also a bit redundant: If I want to know whether the underlying type is nullable, then (it seems to me) I can find that out from the FieldType property. Anyway... in the scenario I've described, what would be the simplest way of telling if the field is (database) nullable? Thanks. |
|
|
Yep thats a fair point. As a bit more context, the EntityInfo/FieldInfo reflects the information we have available in our internal model at runtime where as the information in the designer is a seperate representation (since this is information describing the model prior to code gen). The designer understands if the database field should be nullable based on that flag but the runtime model does not know this (or make any assumptions) since it is working on the basis that whatever you have assigned as the value is the value that should be sent down to the database. So for strings and other reference types where they can always be nullable (but may not be in the underlying database field) you need to make sure you add a ValidatePresence validate to these to allow LightSpeed to perform a validation check to see if there is actual data set on the field prior to trying to persist. So you can check if the field has a ValidatePresence validation applied or if it is IsNullable = false (which will be true of value types where they are not nullable).
|
|