コード例 #1
0
        public void InsertMultipleUser()
        {
            var user_1 = new User
            {
                Account  = "*****@*****.**",
                Password = "******",
                Type     = UserType.admin
            };
            var user_2 = new User
            {
                Account  = "*****@*****.**",
                Password = "******",
                Type     = UserType.user
            };
            var user_3 = new User
            {
                Account  = "*****@*****.**",
                Password = "******",
                Type     = UserType.user
            };

            using (var context = new RentalCarDb())
            {
                context.Database.Log = Console.WriteLine;
                context.Users.AddRange(new List <User> {
                    user_1, user_2, user_3
                });
                context.SaveChanges();
            }
        }
コード例 #2
0
 public List <RenCar> GetAllRentalCars()
 {
     using (var context = new RentalCarDb())
     {
         return((from e in context.Cars
                 select e).ToList());
     }
 }
コード例 #3
0
 public void InsertUser(User user)
 {
     using (var context = new RentalCarDb())
     {
         context.Database.Log = Console.WriteLine;
         context.Users.Add(user);
         context.SaveChanges();
     }
 }