Information générale
Catégorie:
The Mere Mortals .NET Framework
Titre:
Checking for a Null value
I am validating data for a row. When I check to see if a column contains valid data, I get an exception if it contains a null (InventoryPK is a required and non-null column)
if (Ent.InventoryPK == null)...
If it contains null, I want to set the value. However, obviously, if it contains a value I don't want to change it.
The options I see are:
- Put the whole thing in a try-catch and if I get the exception, assign it.
- Check against the DataRow, in which case I lose the advantage of Entities
I'm not real crazy about either, so I'm looking for a better solution.
In the entity class, there is a check to see if the Row is null, in which case it returns whatever default value the local variable is set to. Would it make sense to also check to see if the column itself is null and return the same value?
Thanks,
Jeff
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement