Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking for valid Guid in DataRow
Message
De
22/09/2008 14:36:31
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
22/09/2008 14:25:44
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01349517
Message ID:
01349585
Vues:
18
>>>
>>>Top of my head I don't think Guid is a nullable type so the second part is probably uneccessary anyway. Maybe:
>>>
>>>if (dr["Track_Id"] is Guid && (Guid)dr["Track_Id"] != Guid.Emptyl)
>>>but that may be overkill ?
>>
>>Hmm, well I was thinking since the DataRow was derived from a serialized read it could get left null. Paul posted a suggestion for that.
>
>I like mine better than Paul's (g) - it quarantees the second expression won't fail (i.e. the cast to Guid will work) ; Paul's checks that it's not null but NOT that it is indeed a Guid....
>

It does in deed. I am realizing how much I don't know about this un-typed data stuff. I suppose the possibilities become many as to what could be in that column if you don't have control over the data. In this case I am not pulling it from an actual table but rather from an xml file so it could be almost anything. I wish I could get this done another way now that I see the issues. I tried to use the MM Entity objects that are type safe, but had some problems in making it framework aware. More research...
Tim
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform