I have some repositories in a .NET Standard 2.1 class library that were working fine with MySQL. Now that I have moved over to Microsoft SQL Server for Linux (hosted on Ubuntu 20.04) I am finding that SQL code sent via ExecuteAsync does not actually reach the MS SQL server. Other methods, like Dapper Plus's BulkInsert, and even SELECTs sent via QueryAsync work just fine.
To test this, I replaced the SQL code with "hello" and did not get an exception. I did get an exception trying to execute "hello" with Execute. Ergo, this seems to be a Dapper issue rather than a SQL Server issue. I have used Dapper plenty with SQL Server hosted on Windows and have never encountered this, so I suspect this is only reproducible with a Linux-hosted SQL Server (especially considering how new SQL Server for Linux is).
This does not throw an exception or get executed on the SQL Server:
public Task Reset(int id)
{
var sql = @"DELETE FROM Customers WHERE ID= @id";
using (var connection = new SqlConnection(connString))
return connection.ExecuteAsync(sql, new { id});
}
This does not throw an exception either:
public Task Reset(int id)
{
var sql = @"hello!";
using (var connection = new SqlConnection(connString))
return connection.ExecuteAsync(sql, new { id});
}
This DOES work (and an exception is thrown if the sql string is "hello!":
public int Reset(int id)
{
var sql = @"DELETE FROM Customers WHERE ID= @id";
using (var connection = new SqlConnection(connString))
return connection.Execute(sql, new { id });
}
I have some repositories in a .NET Standard 2.1 class library that were working fine with MySQL. Now that I have moved over to Microsoft SQL Server for Linux (hosted on Ubuntu 20.04) I am finding that SQL code sent via ExecuteAsync does not actually reach the MS SQL server. Other methods, like Dapper Plus's BulkInsert, and even
SELECTs sent via QueryAsync work just fine.To test this, I replaced the SQL code with "hello" and did not get an exception. I did get an exception trying to execute "hello" with
Execute. Ergo, this seems to be a Dapper issue rather than a SQL Server issue. I have used Dapper plenty with SQL Server hosted on Windows and have never encountered this, so I suspect this is only reproducible with a Linux-hosted SQL Server (especially considering how new SQL Server for Linux is).This does not throw an exception or get executed on the SQL Server:
This does not throw an exception either:
This DOES work (and an exception is thrown if the sql string is "hello!":