我正在将我的 .NET MVC5 模板转换为 ASPNETZERO 的 .NET Core MVC 模板。因此,我正在转换的所有代码都按照我在 MVC5 模板解决方案中的需要工作。我的方法代码如下所示。
public async Task<EditCompanyDto> GetCompanyForEdit(NullableIdDto input)
{
var companyEditDto = (await _companyRepository.GetAsync((int)input.Id));
var cmp = companyEditDto.MapTo<EditCompanyDto>();
return cmp;
}
此代码在 MVC5 模板中完美运行,并返回 Address、Contact 和 Note 的相关实体。在 .NET Core 解决方案中,此完全相同的代码仅返回上述方法中的 Address 和 Contact 集合。它不断将 Note 集合返回为 NULL。
下面显示的是我的公司实体。我删除了这篇文章的一些字段,但保留了所有导航属性。
public class Company : FullAuditedEntity, IMustHaveTenant
{
public string CompanyTaxId { get; set; }
public bool ActiveYesNo { get; set; }
public virtual NoteHeader Note { get; set; }
public virtual List<CompanyAddress> Addresses { get; set; }
public virtual List<CompanyContact> Contacts { get; set; }
public virtual int TenantId { get; set; }
public Company()
{
Addresses = new List<CompanyAddress>();
Contacts = new List<CompanyContact>();
}
}