I am using Connection.db.Single<Test>("select * from Test WHERE ID= " + id) for a test as follows:
Assert.IsNull(Connection.db.Single<Test>("select * from Test WHERE ID= " + id));
I know that the resultset should be a null as there is no row for the value of id I am passing. However, an error is fired as follows:
Sequence contains no elements and exception details is as follows: System.InvalidOperationException was unhandled by user code
Message=Sequence contains no elements
Source=System.Core
StackTrace:
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at PetaPoco.Database.Single[T](String sql, Object[] args) in C:\Dev\Models\PetaPoco.cs:line 1120
- Can`t I use Single to test null?
- Is there a better method to test the Asset.IsNUll ?
Use: