コード例 #1
0
 public void Create(DalQuestion entity)
 {
     if (entity != null)
     {
         context.Questions.Add(entity.ToOrmQuestion());
     }
 }
コード例 #2
0
        public void CreateAndUpdateTestId(DalQuestion entity, int testId)
        {
            var question = entity.ToOrmQuestion();
            var test     = context.Set <Test>().FirstOrDefault(t => t.Id == testId);

            test.Questions.Add(question);
            context.Set <Question>().Add(question);
        }
コード例 #3
0
        public void Delete(DalQuestion entity)
        {
            var ormQuestion = entity.ToOrmQuestion();
            var question    = context.Set <Question>().FirstOrDefault(u => u.Id == ormQuestion.Id);

            context.Set <Question>().Attach(question);
            context.Set <Question>().Remove(question);
            context.Entry(question).State = System.Data.Entity.EntityState.Deleted;
        }
コード例 #4
0
 public void Update(DalQuestion entity)
 {
     if (entity != null)
     {
         var questionToUpdate = context.Set <Question>().FirstOrDefault(u => u.Id == entity.Id);
         var ormQuestion      = entity.ToOrmQuestion();
         context.Set <Question>().Attach(questionToUpdate);
         questionToUpdate.Text = ormQuestion.Text;
         context.Entry(questionToUpdate).State = System.Data.Entity.EntityState.Modified;
     }
 }
コード例 #5
0
        public void Create(DalQuestion entity)
        {
            var question = entity.ToOrmQuestion();

            context.Set <Question>().Add(question);
        }