0

我有三种内容类型:applicationRecord、ApplicationDetailRecord 和 CustomerPartRecord,我的 applicationRecord 如下所示:

    public virtual int Id { get; set; }
    public virtual int CustomerId { get; set; }
    public virtual DateTime CreatedAt { get; set; }
    public virtual ApplicationStatus Status { get; set; }
    public virtual CustomerPartRecord customer { get; set; }
    public virtual IList<ApplicationDetailRecord> Details { get; protected set; }

现在在我的 applicationService 中,我有一个 getApplications() 函数,如下所示:

    public IQueryable<ApplicationRecord> GetApplications()
            {
                return _applicationRepository.Table;
            }

当它运行时,它返回所有 ApplicationDetailRecords 但不返回 CustomerRecord。我的迁移文件中还定义了两个外键,它们是

        SchemaBuilder.CreateForeignKey("Application_Customer", "ApplicationRecord", new[] { "CustomerId" }, "CustomerPartRecord", new[] { "Id" });
        SchemaBuilder.CreateForeignKey("ApplicationDetail_Application", "ApplicationDetailRecord", new[] { "ApplicationRecord_Id" }, "ApplicationRecord", new[] { "Id" });

我看不出客户记录没有被退回的任何原因,我错过了什么吗?我将如何让这个工作?

4

1 回答 1

0

好的找到了答案,我在ApplicationRecord中的customerId需要是Customer_Id,之后一切正常!

于 2013-07-22T08:54:11.230 回答