[英]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.