How Dapper.NET works internally with .Count() and SingleOrDefault()?

Viewed 3361

I am new to Dapper though I am aware about ORMs and DAL and have implemented DAL with NHibernate earlier.

Example Query: -

string sql = "SELECT * FROM MyTable";
public int GetCount()
{
    var result = Connection.Query<MyTablePoco>(sql).Count();
    return result;
}

Will Dapper convert this query (internally) to SELECT COUNT(*) FROM MyTable looking at .Count() at the end?

Similarly, will it convert to SELECT TOP 1 * FROM MyTable in case of SingleOrDefault()?

I came from NHibernate world where it generates query accordingly. I am not sure about Dapper though. As I am working with MS Access, I do not see a way to check the query generated.

1 Answers
Related