【问题标题】:Nested object routing with ServiceStack使用 ServiceStack 的嵌套对象路由
【发布时间】:2013-08-31 03:09:20
【问题描述】:

我想设置类似下面的东西,因为它是一个更清洁的 POCO 设计,但似乎我只能通过创建 intUserId 属性而不是延迟加载的 POCO 来完成这项工作。

[Route("/Accounts", "GET")]  //Where I want to be able to do /Accounts?UserId=1234 
[Route("/Accounts/{Id}", "GET")] 
public class Account
{
  public User User {get;set;}
  public int Id {get;set;}
  ...
}

public class User
{
  public int Id {get;set;}
  ...Lazily loaded values
}

这是唯一的选择吗?

public class Account
{
  public int UserId {get;set;}
  public int Id {get;set;}
  ...
}

【问题讨论】:

    标签: rest routes servicestack


    【解决方案1】:

    Account 类是您的请求吗?请参阅 wiki 以了解如何使用路由装饰您的请求 dto,https://github.com/ServiceStack/ServiceStack/wiki/Routing

    【讨论】:

    • 投了反对票,因为我已经展示了我对基本路由的理解(这是 wiki 中的内容)。我希望可以识别嵌套项 (Account.User.Id)
    • 只是想帮忙。 FTIW 我只看到了执行 wiki 中提到的示例和单元测试。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多