示例#1
0
 public static void RemoveQuestion(Question que)
 {
     using (var db = new FriendTestEntities())
     {
         int id      = que.ID;
         var answers = from ans in db.Answer
                       where ans.ID_question == id
                       select ans;
         foreach (Answer item in answers)
         {
             db.Answer.Remove(item);
         }
         db.SaveChanges();
         var quest = from q in db.Question
                     where q.ID == id
                     select q;
         foreach (Question q in quest)
         {
             db.Question.Remove(q);
         }
         db.SaveChanges();
     }
 }
示例#2
0
 public void AddPerson(Person p)
 {
     db.Person.Add(p);
     db.SaveChanges();
 }