-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Is there a way to setup/define dynamic parameter as in Dapper? #1051
Comments
AFAIK, RepoDB is leveraging the default behavior of ADO.NET when passing the parameters via parameterized SQL. But allow us to double check this. There is no other way to override the data type you passed into the parameter, unlesd of course you use the type mapper. Have you also tried using the QueryField and see if that has change the thing? See here |
@mikependon |
Example from https://repodb.net/operation/executequery#queryfieldquerygroup: var param = new QueryGroup(new []
{
new QueryField("Id", 10045)
}); I wish to have: var param = new QueryGroup(new []
{
new QueryField("Id", DBType.AnsiString,10045)
}); |
If we would like to have it var results = await _connection.ExecuteQueryMultipleAsync(
query,
new { Id = new Microsoft.Data.SqlClient.SqlParameter("Id", SqlDbType.VarChar) }
); |
Yes, we got it. But, there is a logic behind where RepoDB auto detects the type of the column from the DB table and associate the proper type to your command parameter, but AFAIK, by executing via raw SQL it is leveraging the default behavior of ADO. So the NVARCHAR(*) is something like ADO.NET default behavior. |
Unfortunately using classes and no raw SQL is not an option in the company that I'm working in. I will create enhancement request for |
That would work. We will look on this enhancement request afterwards. |
No description provided. |
I've got RAW SQL + expando object with parameters list and in the database field that I'm looking for is of type
VARCHAR(200)
and mystring
parameter is parsed by repoDB toNVARCHAR(XXX)
which causes slow performance when querying data.I mitigate this issue by using:
but I'd rather to have something like in dapper:
reference: https://www.learndapper.com/parameters
Is it doable in the repodb? Can we select datatype for a query parameters?
The text was updated successfully, but these errors were encountered: