Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Dapper.Contrib INSERT (list) needs the table name to be Plural with an "s" at the end

Open
#115 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
backend, database

Research direction

Start at Dapper.Contrib/SqlMapperExtensions.cs line 384, referenced in the call stack for Insert, and reproduce the list insert with a Ping POCO and a table named Ping. Compare the generated table name with the single-entity and insert-many examples, then verify the expected behavior for singular and plural table names.

Written by the indexing model from the issue text.

Description

Hello guys!

Thanks for this project, it's helping me a lot.
I found what I think to be a bug, please correct me if I am wrong.

Using the example for "Insert Many" from this link :

`using (var connection = My.ConnectionFactory())
{
connection.Open();

var list = new List<InvoiceContrib>
{
    new InvoiceContrib {Kind = InvoiceKind.WebInvoice, Code = "Insert_Many_1"},
    new InvoiceContrib {Kind = InvoiceKind.WebInvoice, Code = "Insert_Many_2"},
    new InvoiceContrib {Kind = InvoiceKind.StoreInvoice, Code = "Insert_Many_3"}
};

var identity = connection.Insert(list);

}`

I noticed that, the table name in this case will need to be InvoiceContribs - otherwise an error as below will be thrown:

System.Data.SqlClient.SqlException
HResult=0x80131904
Message=Invalid object name 'Pings'.
Source=Core .Net SqlClient Data Provider
StackTrace:

For instance. My POCO is called "Ping" - and my table name was "Ping" - but the error said Invalid object name 'Pings'. As soon as I renamed the table to Pings it worked.

Call Stack:

StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition& command) in //Dapper/SqlMapper.cs:line 554
at Dapper.SqlMapper.Execute(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Nullable1 commandTimeout, Nullable1 commandType) in /
/Dapper/SqlMapper.cs:line 443
at Dapper.Contrib.Extensions.SqlMapperExtensions.Insert[T](IDbConnection connection, T entityToInsert, IDbTransaction transaction, Nullable`1 commandTimeout) in /_/Dapper.Contrib/SqlMapperExtensions.cs:line 384

Can anyone please confirm this issue?

Thanks!
Alex

Dominant language
C#
Stars
294
Forks
108
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DapperLib/Dapper.Contrib

All issues in DapperLib/Dapper.Contrib

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.