Why does Dapper's .Execute(…) return an int?

孤街醉人 提交于 2019-12-04 14:57:45

问题


Anyone know why Dapper returns an int from .Execute(...) ?

I can't find this documented anywhere.


回答1:


The integer represents the number of rows that were affected by your query.

It returns an integer so you know if your query has worked. If zero is returned and you expected something to have changed then you know there is a problem.




回答2:


Because DbCommand.ExecuteNonQuery (which Dapper uses internally, no doubt) returns an int for the number of rows affected. Why? Because it's more or less free, and is about the only thing that you can reasonably return for a generic INSERT or UPDATE.



来源:https://stackoverflow.com/questions/33436818/why-does-dappers-execute-return-an-int

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