无效的索引n此SqlParameterCollection以计数= M [英] Invalid index n for this SqlParameterCollection with Count=m

查看:428
本文介绍了无效的索引n此SqlParameterCollection以计数= M的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到的城堡活动记录这个讨厌的错误(缠NHibernate的),当我试图保存一个类:

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

无效的折射率n此SqlParameterCollection以计数= M

我知道这个错误是由财产造成被多次映射中的一类,但是我不知道怎么去解决它。我有两个映射回类问题使用同一列(IpAddressNumber)两个子类。还IpAddressNumber是类,这导致NHibernate的尝试的IpAddressNumber属性三次映射的主键(只是一个猜测。)

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.)

下面是类:

[ActiveRecord(Lazy=true)]
    public class DeviceConfiguration : UsersDatabase<DeviceConfiguration>
    {
        [PrimaryKey]
        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; }
}

任何帮助将是很大的AP preciated ...

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.

这篇关于无效的索引n此SqlParameterCollection以计数= M的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆