public ConfiguradorParametro(Configurador <TObjeto> configurador, string nome) { _configurador = configurador; _nome = nome; }
private IList <object> CarregarRelacionamentoVinculado(TiposRelacionamento tipo, Configurador <TObjeto> configurador, PropertyInfo propriedade) { var item = _dicionario.ConsultarPorPropriedade(propriedade.Name); configurador.Preparar(); var scriptPadrao = configurador.ConsultarScript(); if (item.Ligacao == null) { throw new NaoFoiPossivelEncontrarALigacaoEntreOsCamposException(); } var scriptPersonalizado = (tipo == TiposRelacionamento.Ascendente) ? _relacionamentoBuilder.CriarScriptConsultaRelacionamentoAscendente(item.Ligacao, scriptPadrao) : _relacionamentoBuilder.CriarScriptConsultaRelacionamentoDescendente(item.Ligacao, scriptPadrao, _dicionario.ConsultarCamposChave()); configurador.PersonalizarScript(scriptPersonalizado); IDataReader reader; try { reader = _comando.ConsultarRegistro(configurador); } catch (Exception ex) { throw new NaoFoiPossivelConsultarRelacionamentoVinculadoDevidoAoSeguinteErroException(_dicionario.AliasOuNome, tipo.ToString(), item.Ligacao.Dicionario.AliasOuNome, ex.Message); } var tipoModel = (tipo == TiposRelacionamento.Ascendente) ? propriedade.PropertyType : propriedade.PropertyType.GetGenericArguments()[0]; try { return(Conversor.ConverterDataReaderParaObjeto(tipoModel, reader).Cast <object>().ToList()); } finally { reader.Close(); } }