Am I doing this correct? I'm interested to know the possible reasons why its failing?
Object obj = Find(id); //returns the object. if not found, returns null
if (!Object.ReferenceEquals(obj, null))
{
//do stuff
}
else
{
//do stuff
}
Find Method (Uses ORM Dapper). Performed unit tests on this, I believe there is no problem with this method.
public Object Find(string id)
{
var result = this.db.QueryMultiple("GetDetails", new { Id = id }, commandType: CommandType.StoredProcedure);
var obj = result.Read<Object>().SingleOrDefault();
return obj;
}
Try this:
Object obj = Find(id); //returns the object. if not found, returns null
if (obj != null)
{
//do stuff when obj is not null
}
else
{
//do stuff when obj is null
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With