开发者

Invalid index n for this SqlParameterCollection with Count=m

开发者 https://www.devze.com 2023-02-12 19:47 出处:网络
I\'m getting this nasty error in Castle Active Record (wrapped around NHibernate) when I try to save a class:

I'm getting this nasty error in Castle Active Record (wrapped around NHibernate) when I try to save a class:

Invalid index n for this SqlParameterCollection with Count=m

I know that this error is caused by a property being mapped multiple times in a class however I'm not sure how to get around it. I have two child classes that both map back to the class in question using the same column (IpAddressNumber). Also IpAddressNumber is the primary key of the class, which results in NHibernate trying to map the IpAddressNumber property three times (just a guess.)

Here is the class:

[ActiveRecord(Lazy=true)]
    public class DeviceConfiguration : UsersDatabase<DeviceConfiguration>
    {
        [PrimaryKe开发者_开发技巧y]
        public virtual long IPAddressNumber { get; set; }

        [BelongsTo("IPAddressNumber", Lazy = FetchWhen.OnInvoke)]
        public virtual Vehicle Vehicle { get; set; }

        [BelongsTo("IPAddressNumber", Lazy = FetchWhen.OnInvoke)]
        public virtual JBusConfiguration JBusConfiguration { get; set; }
}

Any help would be greatly appreciated...


I ended up having to just remove the second association altogether to get around this issue. Not a great solution but the only one I could find.

0

精彩评论

暂无评论...
验证码 换一张
取 消