我有三种内容类型: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" });
我无法看到客户记录没有被退回的任何原因,我错过了什么?我怎么会这样工作?
答案 0 :(得分:0)
好的找到答案,我在ApplicationRecord中的customerId需要是Customer_Id,之后一切正常!