Reputation: 3864
I am finding difficulties in validating the following
if(personDS.person[0].IdFk!= DBNull.Value)
this is the compile time error - cannot be applied to operands of type 'System.Guid and 'System.Dbnull'
Upvotes: 2
Views: 9024
Reputation: 2775
Is IdFk declared as nullable ? Es:
public Guid? Idfk
If so you can :
if(personDS.person[0].IdFk.HasValue)
Upvotes: 0
Reputation: 3331
Id is a Guid, which is a Value type and will therefore never equal DBNull.Value. Before I can fully help, I will need to know the types of personDS
(DataSet maybe?) and person
(DataTable maybe). Assuming so, then maybe:
if (!personDS.person[0].IsNull("IdFK"))
If person
is not a DataTable but a class then check for either IdFk == Guid.Empty
, if IdFk
is a Guid, or IdFk == null
if IdFk
is Guid?
.
Upvotes: 0
Reputation: 15931
You can also check against an empty Guid
if (personDS.person[0].IdFk == Guid.Empty )
Upvotes: 0