简体   繁体   English

索引超出范围。 必须为非负数并且小于Nhibernate中的集合错误大小

[英]Index was out of range. Must be non-negative and less than the size of the collection error in Nhibernate

I receive the exception 我收到例外

Index was out of range. 索引超出范围。 Must be non-negative and less than the size of the collection 必须为非负数且小于集合的大小

when i try to SaveOrUpdate a Bsa object. 当我尝试保存或SaveOrUpdate对象时。 I think the problem is that i map the same row twice, once as a property and once as a List of children. 我认为问题在于我将同一行映射两次,一次作为属性,一次作为子列表。

    public BsaMap()
    {
        Schema("MYS");
        Table("BSA");
        Id(x => x.Id, "BSA_S").GeneratedBy.TriggerIdentity();
        HasMany(x => x.BitTypeList).KeyColumn("BSA_S").Fetch.Subselect().Inverse().Not.LazyLoad().Cascade.SaveUpdate();
    }

One Bsa has many BitTypes, and each BitType got the BSA_S as its foreign key. 一个Bsa有许多BitType,每个BitType都有BSA_S作为其外键。 How should i map this, to avoid the error? 我应该如何映射这个,以避免错误? I like having the I'd like to keep the BSA_S as a property field. 我希望将BSA_S保留为属性字段。

Any advice? 有什么建议吗?

Found the problem. 找到了问题。 In The BitType entity, i had mapped BSA_S twice, one as: 在BitType实体中,我已两次映射BSA_S,一次为:

Map(x => x.BsaS).Column("BSA_S"); 

and: 和:

References(x => x.Parent).Column("BSA_S").Cascade.None().Not.LazyLoad().Not.Nullable();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:索引超出范围。 必须是非负的并且小于集合的大小 - Error: Index was out of range. Must be non-negative and less than the size of the collection 错误:System.ArgumentOutOfRangeException:索引超出范围。 必须为非负数且小于集合的大小 - Error: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection 错误C#:索引超出范围。 必须为非负数且小于集合的大小 - Error C#: Index was out of range. Must be non-negative and less than the size of the collection 索引超出范围。 必须为非负数并且小于集合错误的大小 - Index was out of range. Must be non-negative and less than the size of the collection error excpetion error:索引超出范围。 必须是非负数且小于集合的大小 - excpetion error :Index was out of range. Must be non-negative and less than the size of the collection 错误索引超出范围。 必须是非负数且小于集合的大小 - Error Index was out of range. Must be non-negative and less than the size of the collection 超出范围但它有效,索引超出范围。 必须是非负数且小于集合的大小 - Out of Range but it works, Index was out of range. Must be non-negative and less than the size of the collection 获取'索引超出范围。 必须是非负的并且小于集合的大小。 保存 NHibernate 实体时 - Getting 'Index was out of range. Must be non-negative and less than the size of the collection.' when saving a NHibernate entity 索引超出范围。 必须为非负数并且小于集合的大小。 参数名称:索引 - Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index 指数超出范围。 必须是非负数且小于集合的大小。 参数名称:index - Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM