I'm making a page to generate a report. In this I make 3 different selects , placing the result of each query in a list:
public IEnumerable<RelatorioVencerVencidos> ObterRelatorioVencerVencidos(ParametrosVencerVencidos filtro)
{
var hash = new Dictionary<int, RelatorioVencerVencidos>();
CarregarListVencerVencidos(hash,filtro);
CombinarComDadosDeRendaFixa(hash);
CombinarComDadosDeClubes(hash);
return hash.Values.ToArray();
}
private void CombinarComDadosDeClubes(Dictionary<int, RelatorioVencerVencidos> hash)
{
foreach (var clubes in Instance.ObterClubesVirtual())
{
if (hash.ContainsKey(clubes.CodCotista))
hash[clubes.CodCotista].Clubes = clubes.SaldoBruto;
}
}
private void CombinarComDadosDeRendaFixa(Dictionary<int, RelatorioVencerVencidos> hash)
{
foreach (var renda in Instance.ObterRendaFixaVirtual())
{
var codCliente = default(int);
if (int.TryParse(renda.CodCliente, out codCliente))
if (hash.ContainsKey(codCliente))
hash[codCliente].RendaFixa = renda.ValorBruto;
}
}
public void CarregarListVencerVencidos(Dictionary<int, RelatorioVencerVencidos> hash, ParametrosVencerVencidos filtros)
{
foreach (var i in Instance.ObterDadosVencerVencidos(filtro))
{
if (!hash.ContainsKey(i.CodigoBovespa))
hash.Add(i.CodigoBovespa, i);
}
}
I'm editing the question, because I've done it the way above, using Dictionary, where I load the lists into a dictionary using the client code as the key and get the client's balance as a dictionary value. Only one thing that is not working very well is due to my method GetDataVencerVencidos that is in the last foreach that receives some parameters and the parameters end up being zeroed being that in the method GetReportVencerVencidos the Parametros are with values, however when it enters the method LoadListVencer the parameters they are null and I am not able to know the correct way to get the parameter information in the method GetDataVencerVencidos.