Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking for a Null value
Message
De
31/01/2007 18:51:14
Jeff Corder
Ambit Technologies, LLC
Missouri, États-Unis
 
 
À
31/01/2007 14:09:05
James Hansen
Canyon Country Consulting
Flagstaff, Arizona, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01190997
Message ID:
01191206
Vues:
11
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
Fil
Voir

Click here to load this message in the networking platform