我有两个 Dto:
[TableName("Address")]
public class AddressDto
{
public int Id { get; set; }
public string Name { get; set; }
public string City { get; set; }
public string Street { get; set; }
public string Building { get; set; }
public string Appartment { get; set; }
public string ZipCode { get; set; }
public string Floor { get; set; }
public DateTime CreatedDate { get; set; }
}
[TableName("DistributionPoint")]
public class DistributionPointDto
{
[Column("Id")]
public int Id { get; set; }
public string Name { get; set; }
[Reference(ReferenceType.Foreign, ColumnName = "AddressId", ReferenceMemberName = "Id")]
public AddressDto Address { get; set; }
}
如何使用 nPoco 获得带有嵌套 AddressDto 的 DistributionPointDto?我有一个用于 CRUD 的通用存储库,方法如下:
public T FindById<T>(int id)
{
return _db.SingleById<T>(id);
}
但是,当我尝试获取 DistributionPointDto 时,AddressDto 是null