Esempio n. 1
0
        private void AddUsers()
        {
            var a = new List <User>();

            a.Add(new User
            {
                Username = "******"
            });
            a.Add(new User
            {
                Username = "******"
            });
            a.Add(new User
            {
                Username = "******"
            });
            a.Add(new User
            {
                Username = "******"
            });
            foreach (var i in a)
            {
                context.Users.Add(i);
            }
            context.SaveChanges();

            using (var db = new DBDataContext())
            {
                db.Users.Add(new User {
                    Username = "******"
                });
                db.SaveChanges();
            }
        }
Esempio n. 2
0
        private void AddData()
        {
            var a = new List <SubjectiveQuestion>();

            a.Add(new SubjectiveQuestion
            {
                QuestionText = "What is the national bird of India?",
                AnswerText   = "Peacock"
            });
            a.Add(new SubjectiveQuestion
            {
                QuestionText = "How many months do we have in a year?",
                AnswerText   = "12"
            });
            a.Add(new SubjectiveQuestion
            {
                QuestionText = "What is 2+2?",
                AnswerText   = "4"
            });
            a.Add(new SubjectiveQuestion
            {
                QuestionText = "How many colors in a rainbow?",
                AnswerText   = "7"
            }); a.Add(new SubjectiveQuestion
            {
                QuestionText = "Which is the smallest planet?",
                AnswerText   = "Mercury"
            });
            a.Add(new SubjectiveQuestion
            {
                QuestionText = "What is the name of planet we live?",
                AnswerText   = "Earth"
            });
            foreach (var i in a)
            {
                context.SubjectiveQuestions.Add(i);
            }
            context.SaveChanges();
        }