相关疑难解决方法(0)

ServiceStack.OrmLite - 如何在外键查找中包含字段?

我正在尝试使用ServiceStack MVC PowerPack,我正在尝试使用包含的OrmLite ORM,并尝试从外键引用的表中获取数据,而不知道如何操作.

例如,在使用Northwind数据库的OrmLite示例中,是否可以返回包含"ShipperTypeName"的Shipper对象作为通过外键"ShipperTypeID"查找的字符串?

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; …
Run Code Online (Sandbox Code Playgroud)

servicestack

4
推荐指数
1
解决办法
7669
查看次数

标签 统计

servicestack ×1