Trying to get data from Shopify by running through loop.
public class OrderList { public List<Order> orders { get; set; } } public class Order { public Order(); public long? Id { get; set; } public Address BillingAddress { get; set; } public string BrowserIp { get; set; } public bool? BuyerAcceptsMarketing { get; set; } public DateTimeOffset? CancelledAt { get; set; } } public List<Order> GetOrdersbyDateRange(DateTime fromdate,DateTime todate) { var totalorders = new List<Order>(); long? lastid = 0; while (true) { var json = _api.Get(string.Format("orders.json?created_at_min={0}&created_at_max={1}&since_id>{2}&limit=250", fromdate.ToString("yyyy-MM-dd"), todate.AddDays(1).ToString("yyyy-MM-dd"), lastid)); //var json = _api.Get(string.Format("orders.json")); var searchorders = JsonConvert.DeserializeObject<OrderList>(json).orders; if (searchorders.Count > 0) { lastid = searchorders[0].Id; totalorders = totalorders.AddRange(searchorders); } else { break; } } return totalorders; }
Getting error near this line totalorders = totalorders.AddRange(searchorders); Error: Cannot implicitly convert type 'void' to System.Collections.Generic.List<ShopifySharp.Order> I'm aware AddRange() does not return anything (void), hence the error. I think m missing some simple point...but not able to fix it. What I have tried: Tried using <pre>totalorders = totalorders.Add(searchorders);
cannot convert from 'System.Collections.Generic.List<ShopifySharp.Order>' to 'ShopifySharp.Order'
AddRange
totalorders =
lastid = searchorders[0].Id; totalorders.AddRange(searchorders);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)