Consider the following codes:
public List<Author> Read()
{
using (IDbConnection db = new SqlConnection
(ConfigurationManager.ConnectionStrings["AdventureWorks"].ConnectionString))
{
string readSp = "GetAllAuthors";
return db.Query<Author>(readSp,commandType: CommandType.StoredProcedure).ToList();
}
}
Why would the example adds commandType: CommandType.StoredProcedure
in the return?
Is it for anti-SQL-injection?
I get the example here: http://www.infoworld.com/article/3025784/application-development/how-to-work-with-dapper-in-c.html
To tell the query that it is a StoredProcedure. Also try to look on this MSDN documentation CommandType Enumeration and SQLCommand CommandType Property.