I have the api method that returns a Products list: getAllProduct() returns filled list including:
List<Product> dependProduct
but the client receives an empty dependProduct.
public class Product
{
public string Title { get; set; }
public int Cost { get; set; }
public List<Product> dependProduct = new List<Product>();
}
Controller:
[Route("~/Shop/Product")]
[ResponseType(typeof(IEnumerable<Product>))]
public HttpResponseMessage Get()
{
var data = getAllProduct(); // has dependProduct
return this.Request.CreateResponse(HttpStatusCode.OK, data);
}
private List<Product> getAllProduct()
{
return context.Products.ToList();
}
Client:
var request = new RestRequest("/Shop/Product", Method.GET);
var response = client.Execute<List<Product>>(request);
return response.Data; // has not dependProduct why?