Dapper
Dapper copied to clipboard
Mixing public and internal properties in public class causes Dapper to not recognize internal properties.
While trying to mix public and internal properties in a class Dapper doesn't map internal properties to parameters in the query.
How to reproduce it:
using IDbConnection connection = new SqlConnection("Server=.;Initial Catalog=TestDB;...");
connection.Open();
var testClass = new TestClass { ValueA01 = "Test", ValueA02 = 10 };
var result = connection.Execute("INSERT INTO TableA VALUES (@ValueA01, @ValueA02)", testClass);
if(connection.State == ConnectionState.Open)
{
connection.Close();
}
public class TestClass
{
public string ValueA01 { get; set; } = string.Empty;
internal int ValueA02 { get; set; }
}
Error message:
Microsoft.Data.SqlClient.SqlException (0x80131904): Must declare the scalar variable "@ValueA02"