MicroOrm.Dapper.Repositories SqlGenerator param - where to get that?

dapper

Question

Im trying to use the MicroOrm.Dapper.Repositories but the usage sample left me hanging on where to get the SqlGenerator object. It's sample documentation is:

public UserRepository(IDbConnection connection, ISqlGenerator<User> sqlGenerator)
    : base(connection, sqlGenerator)
{

Amy I using this right:

var conn = new MySqlConnection("connectionStringXYZ");
var generator = new SqlGenerator<User>();
var userRepo = new UserRepository(conn, generator);

which gives me internal server error 500.

Popular Answer

You should be able to do:

ISqlGenerator<User> userSqlGenerator = new SqlGenerator<User>(ESqlConnector.MySQL);

Preferably the generator should be a singleton, possibly an injected one.

But your error is an http error, so I suppose you are swallowing the real exception somewhere in your application. Find out the underlying reason.



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why