Hi,
I have the following method:
function TCompraOperadoraPedidoDAO.GetPedidosColetados(
aCodCompraOperadora: Integer): ICollection<TIdPedidoAlocacao>;
var
Query: IQuery;
begin
Result := TCollections.CreateList<TIdPedidoAlocacao>;
Query := GetQuery;
Query.SQL.Add('SELECT PF.CODPEDIDO, PF.CODCLIENTE_ALOCACAO, MIN(coalesce(CO.COLETADA, ''S'')) COLETADA');
...
Query.Open;
while not Query.Eof do
begin
if Query.FieldByName('COLETADA').AsString = 'S' then
Result.Add(TIdPedidoAlocacao.Create(Query.FieldByName('CODPEDIDO').AsInteger,
Query.FieldByName('CODCLIENTE_ALOCACAO').AsInteger));
Query.Next;
end;
end;
That is used as
PedidosColetados := GetPedidosColetados(Codigo.ToInteger);
for PedidoAlocacao in PedidosColetados do
uPedidoSituacao.MarcaPedidoFilialColetado(PedidoAlocacao.CodPedido,
PedidoAlocacao.CodClienteAlocacao);
I noticed that even when PedidosColetados is empty it enters the loop. What am I doing wrong? Do I need to explicitly check if the collection is not empty?
Thanks in advance;