Information générale
Catégorie:
The Mere Mortals .NET Framework
Jeff,
Do you need to check for (Ent.InventoryPK == DBNull) ?
...Jim
It's the Ent.InventoryPK that causes the error. When the Entity object checks the value using GetNullableDbValue() and the returned value is null, it tries to cast it to the approprieate non-nullable type and since I haven't put any data in it yet, it throws an error.
>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
Précédent
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