Mixing public and internal properties in public class causes Dapper to not recognize internal properties.
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
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"
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start by reproducing the issue with the shown C# class and Execute INSERT call, then trace Dapper's parameter mapping; done means the internal ValueA02 property is recognized and the query executes without the missing-parameter error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100