예제 #1
0
        public static void  PrintUser()
        {
            using (var db = new CreateProjectContext())
            {
                var query = from b in db.Users
                            orderby b.UserName
                            select b;


                foreach (var item in query)
                {
                    Console.WriteLine(item.UserName);
                }
            }
        }
예제 #2
0
        public static bool AddUser()
        {
            try
            {
                using (var db = new CreateProjectContext())
                {
                    var user = new User();
                    user.UserID   = "1";
                    user.UserName = "******";
                    db.Users.Add(user);
                    db.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
            }

            return(false);
        }