-
Notifications
You must be signed in to change notification settings - Fork 97
Don't require parameter name to include prefix #80
Comments
Decided not to do this. We don't know if the user specified their query using |
So in the case of Dapper, they do clean the input and output parameters by removing the prefix before sending it to the driver. It would solve some scenarios if you decided to use |
Reopening, you have a point 😄 |
Should we only auto-prepend '@'? Sqlite can also use these prefixes: (see the docs on param binding)
|
No ordinal parameters. Our choices are |
Most documented sql queries in ADO.NET use '@', if one should be added I think this should be it. |
We decided not to this originally because this introduces a new ambiguity. Consider the following: var command = connection.CreateCommand();
command.CommandText = "SELECT $type, @type, :type";
command.Parameters.AddWithValue("type", 1); Which parameter is bound? If we only prepend var command = connection.CreateCommand();
command.CommandText = "SELECT $type";
command.Parameters.AddWithValue("type", 1); We can add a heuristic that tries first to append |
Right, the first case doesn't work with or without the suggested trick. But in some cases the trick will help. It's not a solution which will solve all cases, but most common ones. |
Here is what I propose (not the actual implementation, but you get the idea): if(!Bind(paramName, value))
{
if(!Bind("@" + paramName, value))
{
if(!Bind("$" + paramName, value))
{
if(!Bind(":" + paramName, value))
{
Fail();
}
}
}
} |
We have two options:
I'll investigate 1 first, but if it's not possible, we'll just do 2. |
SqlClient allows adding a ParameterName without the prefix, such as @, but Sqlite requires the prefix be included.
Example: this works in SqlClient, but with Sqlite the parameter is not bound to @BronieName
The text was updated successfully, but these errors were encountered: