Exemple #1
0
        private void CreateUsers()
        {
            if (!context.Users.Any())
            {
                var user11 = new User()
                {
                    FirstName   = "user11",
                    MiddleName  = "user11",
                    LastName    = "user11",
                    ValidFrom   = DateTime.Now,
                    ValidUntill = DateTime.Now + TimeSpan.FromDays(30)
                };

                var user12 = new User()
                {
                    FirstName   = "user12",
                    MiddleName  = "user12",
                    LastName    = "user12",
                    ValidFrom   = DateTime.Now,
                    ValidUntill = DateTime.Now + TimeSpan.FromDays(30)
                };
                var user13 = new User()
                {
                    FirstName   = "user13",
                    MiddleName  = "user13",
                    LastName    = "user13",
                    ValidFrom   = DateTime.Now,
                    ValidUntill = DateTime.Now + TimeSpan.FromDays(30)
                };
                var user14 = new User()
                {
                    FirstName   = "user14",
                    MiddleName  = "user14",
                    LastName    = "user14",
                    ValidFrom   = DateTime.Now,
                    ValidUntill = DateTime.Now + TimeSpan.FromDays(30)
                };
                context.Users.AddRange(user11, user12, user13, user14);
                var r5 = context.SaveChanges();
            }
        }
 public virtual T Add(T t)
 {
     _context.Set <T>().Add(t);
     _context.SaveChanges();
     return(t);
 }