public void AddTeam(string name, string email, bool isExclusive, bool isActive) { // Initialize the connection string builder for the // underlying provider. EntityConnectionStringBuilder entityBuilder = GetEntityBuilder(); using (EntityConnection conn = new EntityConnection(entityBuilder.ToString())) { using (AMS_DMEntities entities = new AMS_DMEntities(conn)) { Console.WriteLine("connection Ok."); Team team = new Team(); team.Name = name; team.Email = email; team.IsExclusive = isExclusive; team.IsActive = isActive; entities.AddToTeams(team); entities.SaveChanges(); } } }
public void DeleteTeams() { IList<Team> teams = new List<Team>(); EntityConnectionStringBuilder entityBuilder = GetEntityBuilder(); using (EntityConnection conn = new EntityConnection(entityBuilder.ToString())) { using (AMS_DMEntities entities = new AMS_DMEntities(conn)) { teams = entities.Teams.ToList(); for (int i = 0; i < teams.Count; i++) { entities.Teams.DeleteObject(teams[i]); } entities.SaveChanges(); } } }