此 SqlParameterCollection 的 Count=4 的索引 4 无效。
2014-04-21 19:40
1646 查看
NHibernate在做Update()时,报错: 此 SqlParameterCollection 的 Count=4 的索引 4 无效。
原因:
mapping.Map(u => u.OrganizationId).Column("OrganizationId");
mapping.References(u => u.Organization).Column("OrganizationId").NotFound.Ignore();
将OrganizationId列映射了两次。
解决方案:
试了一下,改成
mapping.Map(u => u.OrganizationId).Column("OrganizationId").Not.Insert().Not.Update();
mapping.References(u => u.Organization).Column("OrganizationId").NotFound.Ignore();
或
mapping.Map(u => u.OrganizationId).Column("OrganizationId");
mapping.References(u => u.Organization).Column("OrganizationId").NotFound.Ignore().Not.Insert().Not.Update();
都可以。
参考:
http://stackoverflow.com/questions/8062068/nhibernate-error-message-invalid-index-3-for-this-sqlparametercollection-with-c
http://stackoverflow.com/questions/18125692/invalid-index-6-for-this-sqlparametercollection-with-count-6
原因:
mapping.Map(u => u.OrganizationId).Column("OrganizationId");
mapping.References(u => u.Organization).Column("OrganizationId").NotFound.Ignore();
将OrganizationId列映射了两次。
解决方案:
试了一下,改成
mapping.Map(u => u.OrganizationId).Column("OrganizationId").Not.Insert().Not.Update();
mapping.References(u => u.Organization).Column("OrganizationId").NotFound.Ignore();
或
mapping.Map(u => u.OrganizationId).Column("OrganizationId");
mapping.References(u => u.Organization).Column("OrganizationId").NotFound.Ignore().Not.Insert().Not.Update();
都可以。
参考:
http://stackoverflow.com/questions/8062068/nhibernate-error-message-invalid-index-3-for-this-sqlparametercollection-with-c
http://stackoverflow.com/questions/18125692/invalid-index-6-for-this-sqlparametercollection-with-count-6
相关文章推荐
- 使用NHibernate出现错误"此SqlParameterCollection 的 Count=71 的索引 71 无效"
- 此OracleParameterCollection 的 Count=4 的索引 4 无效 的解决办法 NHibernate
- NHibernate Invalid index N for this SqlParameterCollection with Count=N Exception 简易处理
- 解决异常“SqlParameterCollection 只接受非空的 SqlParameter 类型对象。”
- java.sql.SQLException: 无效的列索引
- The SqlParameter is already contained by another SqlParameterCollection.
- java.sql.SQLException: 无效的列索引
- java.sql.SQLException: 无效的列索引
- Oracle试用PreparedStatement出现java.sql.SQLException: 无效的列索引
- “另一个 SqlParameterCollection 中已包含 SqlParameter”异常
- 出现了“另一个 SqlParameterCollection 中已包含 SqlParameter”异常
- ADO.NET基础必备之SqlParameterCollection 类
- 安卓 此 SqlParameterCollection 中未包含带有 ParameterName“@RETURN_VALUE”的 SqlParameter。
- java.sql.SQLException: 无效的列索引
- 另一个SqlParameterCollection中已包含SqlParameter
- [转]另一个SqlParameterCollection 中已包含 SqlParameter[解决方案]
- 检查管理员exception is java.sql.SQLException: 无效的列索引
- 另一个 SqlParameterCollection 中已包含 SqlParameter
- java.sql.SQLException: 无效的列索引
- java.sql.SQLException: 无效的列索引