public static void Teste() { ContextMainCartNew context = new ContextMainCartNew("contextOraCartNew"); RepositoryPais RepPais = new RepositoryPais(context); List <Pais> listPaizes = RepPais.GetAll().ToList(); //Repository Pais RepPais = new RepositoryPais(context); //using (ufwCart unitOfWork = new UfwCart(BaseDados.DesenvDezesseisNew)) //{ // List<Pais> listPaizes = unitOfWork.Repositories.GenericRepository<Pais>().GetAll().ToList(); // //foreach (var pais in listPaizes) // //{ // // Console.WriteLine(" {0} {1}", pais.Id, pais.NomePais); // //} // //Console.WriteLine("----------------------------fim relatório----------------------"); //} }
private Object GetRepositoryInstance <T>() where T : class { this.VerifyContext(); Object repository = null; try { if (_repositories.Keys.Contains(typeof(T))) { repository = _repositories[typeof(T)] as IRepositoryBaseReadWrite <T>; } else { if (typeof(T).Equals(typeof(Pais))) { repository = new RepositoryPais(this._context); } if (typeof(T).Equals(typeof(Uf))) { repository = new RepositoryUf(this._context); } if (typeof(T).Equals(typeof(Municipio))) { repository = new RepositoryMunicipio(this._context); } if (typeof(T).Equals(typeof(PessoaCartNew))) { repository = new RepositoryPessoaCartNew(this._context); } if (typeof(T).Equals(typeof(ModeloDoc))) { repository = new RepositoryModeloDoc(this._context); } if (typeof(T).Equals(typeof(Ato))) { repository = new RepositoryAto(this._context); } if (typeof(T).Equals(typeof(LogModeloDoc))) { repository = new RepositoryLogModeloDoc(this._context); } if (typeof(T).Equals(typeof(TipoAto))) { repository = new RepositoryTipoAto(this._context); } if (typeof(T).Equals(typeof(Acao))) { repository = new RepositoryAcao(this._context); } if (repository != null) { _repositories.Add(typeof(T), repository); } } if (repository == null) { throw new NullReferenceException("repositório New é nulo!"); } } catch (Exception ex) { throw new Exception("Erro na criação de repositorio, tipo: " + typeof(T).Name + " " + ex.Message); } return(repository); // new TRepository(); }