Hi there,
When I call Order.GetOrders(sql, true) and the SQL statement doesn't result in any orders being returned, the method crashes with an "Incorrect syntax near ')'" error message. It looks like the code to retrieve the order lines runs regardless of whether any orders were found which then leads to issues when building up the WHERE clause.
I can work around it with code like this:
const string sql = "SELECT * FROM EcomOrders WHERE (OrderCart = 0)"; var hasOrders = Order.GetOrders(sql, false).Any(); if (hasOrders) { var orders = Order.GetOrders(sql, true); // process orders here. }
but that feels kind of silly.
Are there other ways to retrieve orders and order lines that doesn't crash when no orders match the SQL statement?
Thanks,
Imar