I am getting the following error:
Invalid index 3 for this OracleParameterCollection with Count=3
when i am attempting to insert a new column into a table.
my entity class is:
public class Operator
{
public Operator()
{
this.OperatorMemberships = new List<OperatorMembership>();
}
public virtual int Id { get; set; }
public virtual int OperatorMembershipId { get; set; }
public virtual int SchemeId { get; set; }
public virtual string Description { get; set; }
public virtual IList<OperatorMembership> OperatorMemberships { get; set; }
}
public class OperatorMembership
{
public virtual int Id { get; set; }
public virtual int OperatorId { get; set; } // delete
public virtual int UserRoleId { get; set; } // delete
public virtual UserRole UserRole { get; set; }
public virtual Operator Operator { get; set; }
}
My mappings are:
public OperatorMap()
{
Table("OPERATOR");
Id(x => x.Id, "OPERATOR_ID").GeneratedBy.Identity();
Map(x => x.SchemeId, "SCHEME_ID");
Map(x => x.Description, "DESCRIPTION");
//HasMany(x => x.OperatorMemberships).Inverse().AsBag().Cascade.AllDeleteOrphan();
HasMany(x => x.OperatorMemberships).Inverse().AsBag();
//References(x => x.SchemeServices, "OPERATOR_ID");
}
}
public class OperatorMembershipMap : ClassMap<OperatorMembership>
{
public OperatorMembershipMap()
{
Table("USER_OPERATOR_MEMBERSHIP");
Id(x => x.Id, "USER_OPERATOR_MEMBERSHIP_ID").GeneratedBy.Identity();
Map(x => x.OperatorId, "OPERATOR_ID");
Map(x => x.UserRoleId, "USER_ROLE_ID");
References(x => x.Operator).Column("OPERATOR_ID"); ;
References(x => x.UserRole).Column("USER_ROLE_ID");
}
}
the code to insert the new row is:
public int AddOperatorMembership(int operatorId, int userRoleId)
{
OperatorMembership op = new OperatorMembership();
op.OperatorId = operatorId;
op.UserRoleId = userRoleId;
_provider.AddEntity(op);
return op.Id;
}
and my database table is:
USER_OPERATOR_MEMBERSHIP_ID -- OPERATOR_ID -- USER_ROLE_ID
any help would be good, i am sure there are some very clever fluent nhibernate developers out there who can spot the error straight away.
many thanks.
Randolf.