Can anyone please suggest how to check if there are any records in the resultset using Dapper ORM.
Customer objCustomer = null;
using (SqlMapper.GridReader multiResult = new DapperRepository().QueryMultiple(sql, new { id = id }))
{
objCustomer = multiResult.Read<Customer>().Single(); //null exception
}
Yes, write this:
objCustomer = multiResult.Read<Customer>().SingleOrDefault(); //return null if not exists without error
then you can check:
objCustomer != null
Hope this helps.