Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking for valid Guid in DataRow
Message
From
22/09/2008 14:36:31
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01349517
Message ID:
01349585
Views:
16
>>>
>>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform