【发布时间】:2016-04-14 07:11:22
【问题描述】:
我有一个典型的反应
ResultModel
{
Bool Result,
Object Response
}
我想发送带有产品的示例类别
var response = new List<Category>
{
new Category {Name = "1", Products = new List<Product> {new Product {Name = "1_1"}, new Product {Name = "1_2"}} },
new Category {Name = "2", Products = new List<Product> {new Product {Name = "2_1"}, new Product {Name = "2_2"}} },
new Category {Name = "3", Products = new List<Product> () },
}
我的回应
return new ResultModel
{
Response = response,
Result = true
};
但我无法收到 Products 属性作为响应。 有人知道为什么吗? 谢谢
【问题讨论】:
-
请添加您遇到的错误
-
没有任何错误。我只收到 Result = true 和 3 个类别,有名称,但没有产品
-
当然我在 Category 和 Product 中有更多的属性。例如,我只展示其中的一些。但它们都很简单 (int, string)
标签: c# api asp.net-web-api