コード例 #1
0
 public void Iserir(Tipo model)
 {
     using (DadosContext contexto = new DadosContext())
     {
         contexto.Tipos.Add(model);
         contexto.SaveChanges();
     }
 }
コード例 #2
0
        public void Editar(Tipo tipo)
        {
            using (DadosContext ctxt = new DadosContext())
            {
                Tipo tipodb = BsucarPorId(tipo.Id);
                if (tipodb != null)
                {
                    tipodb = tipo;

                    ctxt.SaveChanges();
                }
            }
        }
コード例 #3
0
ファイル: Startup.cs プロジェクト: ulili5/lab-netcore
        private void Inicializar(DadosContext context)
        {
            if (context != null)
            {
                context.Database.EnsureCreated();

                if (!context.Usuarios.Any())
                {
                    var fake = new DadosFake();
                    context.Usuarios.AddRange(fake.Usuarios(100));
                    context.SaveChanges();
                }
            }
        }