1

When using query method in Dapper.NET library, the funciton code is here:

public IEnumerable<dynamic> Query(IDbConnection conn, string sql, dynamic param = null, IDbTransaction trans = null, bool buffered = true)
{
    return SqlMapper.Query(conn, sql, param as object, trans, buffered);
}

Our customer use their own data access library, they dont use SqlMapper class in Dapper library. So they need to change param to DbParameter[]. There are many references with Query method, it is better to only change param object to DbParameter array, otherwise we have to modify every reference in our code.

Is there a good way to find a solution to fix this issue? Thanks.

2
  • use IParameter[] which is the interface. Commented Jun 16, 2016 at 7:51
  • @Dr.Snitch that doesn't change much, though... Commented Jun 16, 2016 at 18:02

1 Answer 1

1

This is not an API that dapper exposes, because it never needs that. To do what you want, you could borrow liberally from the dapper source code to get what you need, but also consider: you cannot create a DbParameter in isolation - it is an abstract type. You need to either know in advance what type you actually want, or ask the connection to create the parameters for you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.