Accepted Answer

TOP @param

Is not legal in SQL server. 2 options:

Select Top (@count) * From tblCourse

Or

Select Top {=count} * From tblCourse

The first is SQL-server's way of representing this. The second is a dapper-specific feature that injects integer values (only: it doesn't work for strings) directly into the query. If the value is usually the same, the second will usually perform better. Of course, with the second you'd need a different regex too.