Why is Dapper unable to return multiple inserted row ids?

三世轮回 提交于 2019-12-01 22:16:38

Something, somewhere, needs to loop. You have a sql statement that inserts one row, and code sending in a list. Since you like your SQL in string literals, I would stick to inserting one person at a time, putting the loop in the C# and recovering each id in the C# using SELECT SCOPE_IDENTITY(). You no longer need @InsertedRows, or OUTPUT.

If you really want to loop in SQL, I believe you'll need to look at table valued parameters for passing your list of inserts. Dapper is very happy to return multiple Ids. It's complaining about multiple people as an input parameter.

One day, hopefully soon, we're going to look back at SQL in string literals like we presently look at goat sacrifice.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!