/// <summary> /// Sobreescrita de metodo, usando o virtual posso alterar o comportamento deste metodo /// sobreescrevendo ele /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual T Add(T entity) { _baseContexto.Set <T>().Add(entity); // Poderia implementar aqui o Padrão UnitOfWork _baseContexto.SaveChanges(); return(entity); }
public async Task <T> GetEntityById(int Id) { using (var data = new BaseContexto(_optionsBuilder)) { return(await data.Set <T>().FindAsync(Id)); } }
public static IEnumerable <UsuarioModel> Listar(this UsuarioModel usuario) { using (var contexto = new BaseContexto()) { return(contexto.Set <UsuarioModel>()); } }
public async Task <List <T> > List() { using (var data = new BaseContexto(_optionsBuilder)) { return(await data.Set <T>().AsNoTracking().ToListAsync()); } }
public virtual T Selecionar(int id) { using (var contexto = new BaseContexto()) { return(contexto.Set <T>().Find(id)); } }
public static UsuarioModel Selecionar(this UsuarioModel usuario, int id) { using (var contexto = new BaseContexto()) { return(contexto.Set <UsuarioModel>().Find(id)); } }
public virtual IList <T> Listar() { using (var contexto = new BaseContexto()) { return(contexto.Set <T>().ToList()); } }
public virtual void Incluir(T item) { using (var contexto = new BaseContexto()) { contexto.Set <T>().Add(item); contexto.SaveChanges(); } }
public static void Incluir(this UsuarioModel item) { using (var contexto = new BaseContexto()) { contexto.Set <UsuarioModel>().Add(item); contexto.SaveChanges(); } }
public async Task Update(T Objeto) { using (var data = new BaseContexto(_optionsBuilder)) { data.Set <T>().Update(Objeto); await data.SaveChangesAsync(); } }
public static void Deletar(this UsuarioModel item) { using (var contexto = new BaseContexto()) { contexto.Set <UsuarioModel>().Remove(item); contexto.SaveChanges(); } }
public override IList <VeiculoModel> Listar() { using (var contexto = new BaseContexto()) { return(contexto.Set <VeiculoModel>().Include("TipoVeiculo").ToList()); } //return base.Listar(includes); }
public static IQueryable <UsuarioModel> Listar(this UsuarioModel usuario, params string[] includes) { using (var contexto = new BaseContexto()) { var query = contexto.Set <UsuarioModel>().AsQueryable(); foreach (var include in includes) { query = query.Include(include); } return(query.AsNoTracking()); } }
public virtual IList <T> Listar <TProperty>(params Expression <Func <T, TProperty> >[] includes) { using (var contexto = new BaseContexto()) { var select = contexto.Set <T>().AsQueryable(); foreach (var include in includes) { select = select.Include(include); } return(select.AsNoTracking().ToList()); } }
public void InsertUnitOfWork(T obj) { _context.Set <T>().Add(obj); }
public void Inserir(TEntidade obj) { Db.Set <TEntidade>().Add(obj); Db.SaveChanges(); }
public BaseRepositorio(BaseContexto context) { _context = context; _dbSet = context.Set <T>(); }
public Repositorio() { Db = new BaseContexto(); DbSet = Db.Set <T>(); }