In the MVC 3 project, I use EF4, IoC, and Agatha-RRSL as my level of service.
Fortunately, I found Dapper this week, and I'm moving from EF4 to Dapper!
I usually add a common repository to Agatha request handlers ...
But how do I use Dapper?
1) Should I inject IDbConnection into an Agatha handler? Then inside the handler, do I use it with Dapper Query or Dapper Execute? Can this be verified? What about ridicule?
2) Should I create a shared repository for Dapper? Perhaps the repository will look something like this:
public class Repository { private IDbConnection _connection; public Repository(IDbConnection connection) { _connection = connection; }
And here the IDbConnection will be introduced.
And the repository will be introduced inside the handlers.
I don't know how to check this ...
3) Should I just put all the code inside the handler?
using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Execute(@"insert Roles(Name) values (@name)", new { name = "Role" }); }
But what about testing?
4) I understand that Dapper uses static methods. Doesn't that create a memory problem?
Sorry for so many questions ... I'm trying to get it right.
Thanks Miguel
source share