Just do two things to your original code – remove the `where` constraint, and change the last `return` from `return null` to `return default(T)`. This way you can return whatever type you want. By the way, you can avoid the use of `is` by changing your `if` statement to `if (columnValue != DBNull.Value)`.