Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#115 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
csharp
领域
backend, database

调研方向

从 Insert 调用堆栈中引用的 Dapper.Contrib/SqlMapperExtensions.cs 第 384 行开始,使用一个 Ping POCO 和一个名为 Ping 的表重现列表插入。将生成的表名与单实体和批量插入示例进行比较,然后验证表名为单数和复数时的预期行为。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
C#
星标
293
派生
108
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DapperLib/Dapper.Contrib 的其他 Issue

查看 DapperLib/Dapper.Contrib 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。