Dapper.Contrib INSERT (list) needs the table name to be Plural with an "s" at the end
还没有人认领这个 Issue。
评估
调研方向
从 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,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DapperLib/Dapper.Contrib 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 75/100
DapperLib/Dapper.Contrib#22 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 42/100
DapperLib/Dapper.Contrib#174 ·
-
难度 2/5 1-3 小时 新手友好度 45/100
DapperLib/Dapper.Contrib#173 ·
-
难度 1/5 1 小时以内 新手友好度 10/100
DapperLib/Dapper.Contrib#172 · 1 条评论 · 4 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 48/100
DapperLib/Dapper.Contrib#169 ·
查看 DapperLib/Dapper.Contrib 的全部 Issue
相似的 Issue
-
agentic-workflows area/Docs partner/agentic-workflows
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/fluentui-blazor#5364 ·
维护者通常 1 天内回复
-
.NET triage
难度 2/5 1-3 小时 新手友好度 74/100
microsoft/agent-framework#8811 ·
维护者通常 1 天内回复
-
.NET Docs
难度 1/5 1 小时以内 新手友好度 82/100
getsentry/sentry-dotnet#5637 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
QuantConnect/Lean#9842 ·
维护者通常 1 天内回复