Skip to content

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

Open
@fuine6

Description

@fuine6

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions