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'
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'
try
if(!(personDS.person[0].IdFk is System.DBNull))
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?.
Is IdFk declared as nullable ? Es:
public Guid? Idfk
If so you can :
if(personDS.person[0].IdFk.HasValue)
public starts with a lower p 2) the ? suffix has to be appended to the type, not the identifier 3) if personDS.person[0].IdFK indeed is null the code will throw an InvalidOperationException, else the condition will always be false, since DBNull.Value doesn't equal anything but itself and a Guid can never be of type DBNull (and it won't compile, since you can't compare Guid and DBNull without casting either one to object, which will do a reference comparison)