【问题标题】:Invalid index 1 for this SqlParameterCollection with Count=1此 SqlParameterCollection 的索引 1 无效,Count=1
【发布时间】:2011-10-22 10:05:03
【问题描述】:

我注意到的是,在 Ncv 中,我引用的报告字段没有生成。以下是我收到的错误。

这是我的域的样子,我收到的错误是 Invalid index 1 for this SqlParameterCollection with Count=1。

public class NcvMap : SubclassMap<Ncv>
{
    public NcvMap()
    {
        HasManyToMany<Document>(x => x.Technician)
            .Cascade.All();

        HasManyToMany<Document>(x => x.Neurologist)
            .Cascade.All();

        HasManyToMany<Document>(x => x.Transcriber)
            .Cascade.All();

        References<Document>(x => x.Report).Nullable();
    }
}

public class Ncv : Report
{
    public virtual IList<Document> Technician { get; private set; }
    public virtual IList<Document> Neurologist { get; private set; }
    public virtual IList<Document> Transcriber { get; private set; }
    public virtual Document Report { get; set; }
    public virtual NcvType Type { get; set; }

    public Ncv()
    {
        this.Technician = new List<Document>();
        this.Neurologist = new List<Document>();
        this.Transcriber = new List<Document>();
    }
}

public class Report : BaseModel
{
    public virtual Patient Patient { get; set; }
    public virtual ReportStatus Status { get; set; }
    public virtual DateTime Appointment { get; set; }
    public virtual long Kareo_id { get; set; }
    public virtual IList<ReportLog> Logs { get; private set; }

    public Report() 
    {
        this.Status = ReportStatus.New;
        this.Logs = new List<ReportLog>();
    }

    public virtual void AddLog(ReportLog log)
    {
        log.Report = this;
        this.Logs.Add(log);
    }
}

public class ReportMap : ClassMap<Report>
{
    public ReportMap()
    {
        Id(x => x.Id);
        Map(x => x.CreateDate);
        Map(x => x.LastModified);
        Map(x => x.Appointment);
        Map(x => x.Status).CustomType<int>();
        Map(x => x.Kareo_id);

        HasMany<ReportLog>(x => x.Logs)
            .Cascade.All();

        References<Patient>(x => x.Patient);
    }
}

【问题讨论】:

  • 你应该读取索引 0 因为 c# 数组以 0 开头
  • 索引 0?我什至不确定索引 1 是什么。

标签: c# nhibernate fluent-nhibernate fluent-nhibernate-mapping


【解决方案1】:

好的,问题是在

public class Ncv : Report

我将映射引用命名为与“报告”类相同的名称

public virtual Document Report { get; set; }

因此,请勿使用与类相同的名称来命名您的属性。它破坏了 CreateSchema

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-20
    • 2023-03-28
    • 1970-01-01
    • 2011-06-20
    • 1970-01-01
    相关资源
    最近更新 更多