currently I'm using DTO's and writing my Get Method, which looks like this:
public async Task<IHttpActionResult> GetOrder() {
var order = from x in db.Order
select new OrderDTO {
OrderId = x.OrderId,
orderStatusCode = x.orderStatusCode,
OrderProducts = new List<OrderProductDTO> {
new OrderProductDTO {
OrderId = x.OrderProducts.Select(y => y.OrderId)
}
},
purchaseDate = x.purchaseDate,
quantityOrder = x.quantityOrder,
totalOrderPrice = x.totalOrderPrice,
User = new UserDTO {
UserId = x.UserId,
username = x.User.username,
userInfo = new UserInfoDTO {
adress = x.User.UserInfo.adress,
city = x.User.UserInfo.city,
country= x.User.UserInfo.country,
zip = x.User.UserInfo.zip
}
}
};
return Ok(order);
}
The problem I have is how can I initialize my list dynamically, the error i get is:
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'int'.
I get why the problem occurs but dunno how to fix it, thanks. By the way OrdeProducts is a List.