MySqlConnector icon indicating copy to clipboard operation
MySqlConnector copied to clipboard

Provide alternative methods to ignore missing parameters when Allow User Variables=False.

Open fuine6 opened this issue 4 months ago • 1 comments

Is your feature request related to a problem? Please describe. When Allow User Variables=False, MySql.Data can use @` to ignore missing variables.

For example

var connectionString = "Server=127.0.0.1;User ID=root;Password=123456;Database=test;Allow User Variables=False";

using var connection = new MySql.Data.MySqlClient.MySqlConnection(connectionString);

var sql = @"SELECT 1 INTO @`a`; SELECT @`a`;";

try
{
	int a = await connection.QuerySingleOrDefaultAsync<int>(sql);
	Console.WriteLine($"a: {a}");
}
catch (Exception ex)
{
	Console.WriteLine(ex.Message);
}

Output:

a: 1

Describe the solution you'd like Do this in a similar way.

Additional context I like to use Allow User Variables=False to avoid typos, but I need a way to use variables in special cases.

fuine6 avatar Jun 02 '25 05:06 fuine6