Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixing public and internal properties in public class causes Dapper to not recognize internal properties. #2053

Open
esquijarosa opened this issue Mar 11, 2024 · 0 comments

Comments

@esquijarosa
Copy link

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant