コード例 #1
0
 public void DeleteNinja(int ninjaId)
 {
     using (NinjaContext context = new NinjaContext())
     {
         NijaDomain.Classes.Ninja ninja = context.Ninjas.Find(ninjaId);
         context.Entry(ninja).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
コード例 #2
0
        public void SaveNewEquipment(NinjaEquipment equipment, int ninjaId)
        {
            //paying the price of not having a foreign key here.
            //reason #857 why I prefer foreign keys!
            using (NinjaContext context = new NinjaContext())
            {
                NijaDomain.Classes.Ninja ninja = context.Ninjas.Find(ninjaId);
                ninja.EquipmentOwned.Add(equipment);

                context.SaveChanges();
            }
        }