我正在试用 ServiceStack MVC PowerPack,并正在尝试包含的 OrmLite ORM,并正在尝试从外键引用的表中获取数据,但不知道该怎么做。
例如,在使用 Northwind 数据库的 OrmLite 示例中,是否可以返回一个包含“ShipperTypeName”作为通过外键“ShipperTypeID”查找的字符串的 Shipper 对象?
从http://www.servicestack.net/docs/ormlite/ormlite-overview,如果可能,我想将 ShipperName 字段添加到 Shipper 类:
[Alias("Shippers")]
public class Shipper : IHasId<int>
{
[AutoIncrement]
[Alias("ShipperID")]
public int Id { get; set; }
[Required]
[Index(Unique = true)]
[StringLength(40)]
public string CompanyName { get; set; }
[StringLength(24)]
public string Phone { get; set; }
[References(typeof(ShipperType))]
public int ShipperTypeId { get; set; }
}
[Alias("ShipperTypes")]
public class ShipperType : IHasId<int>
{
[AutoIncrement]
[Alias("ShipperTypeID")]
public int Id { get; set; }
[Required]
[Index(Unique = true)]
[StringLength(40)]
public string Name { get; set; }
}