When i create CYTestDeptTrainWebsite via MVC3, i got blocking issue: Store update, insert, or delete statement affected an unexpected number of rows (0)...
type the solution on here:
In the Album class, you've defined [Bind(Exclude = "AlbumId")] on the class, which means that the code won't try and bind the AlbumId from the form. Which is fine, except that on the edit page, you're passing in a populated Album, which is presumably being
populated using binding, which is of course ignoring the Album Id, so the AlbumId of the object passed into the edit method, is always 0, which throws a misleading concurrency error, because no rows are affected, because there's no album with ID of 0.
If you remove the bind/exclude attribute, then the edit page works as expected.
本文解决了在使用MVC3创建CYTestDeptTrainWebsite过程中遇到的编辑页面并发错误问题,具体表现为更新操作影响了意外数量的行(0行)。问题出现在Album类中定义的[Bind(Exclude=AlbumId)]属性导致编辑页面传入的Album对象的AlbumId始终为0,从而引发错误。移除该绑定排除属性后,编辑功能恢复正常。
4155

被折叠的 条评论
为什么被折叠?



