コード例 #1
0
        public void Remove()
        {
            try
            {
                GamesContext context = new GamesContext();

                context.Entry(this).State = System.Data.Entity.EntityState.Deleted;
                context.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        //SAVE

        public void Save()
        {
            bool create = this.id == 0;

            try
            {
                GamesContext context = new GamesContext();
                if (create)
                {
                    context.Entry(this).State = System.Data.Entity.EntityState.Added;
                }
                else
                {
                    context.Entry(this).State = System.Data.Entity.EntityState.Modified;
                }

                context.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
        }