So I have a list of orders...and if the list is empty I want to to jump to the 'else.'
But because its a list (even if its empty) there still is an instance of it? right? anyway if there are no orders it still goes into the if statement so I tried adding .count == 0
...
but it still goes into the if statement...what do I need to say where if there are no actual records in orders go to 'else....thanks for any replies
IEnumerable<OrderRecord> orders = _orderService.GetOrdersByCustomer(id, OrderStatus.Completed).ToArray();
if (orders != null && orders.Count() == 0 )
{
//order exists
}
else
{
//no order
}