How to force lazy-OR evaluation in VB.NET?

boolean-logic, lazy-evaluation, vb.net

Solution

Use the 'OrElse' operator:

If row.IsNull("MyNullableBooleanField") OrElse row("MyNullableBooleanField") Then

Problem

I am reading in data from a database and putting it in a `DataRow`. I want to test a nullable boolean field for whether it is `Null` or `True`. How can I do the following in VB.NET without it throwing an exception about how the `Or` operator cannot have `DBNull` as one of its operands? Can I force lazy-OR evalution so that is just evaluates the `IsNull` and proceeds no further? `If row.IsNull("MyNullableBooleanField") Or row("MyNullableBooleanField")`

Original source