Esempio n. 1
0
        public void testbdd()
        {
            using (var db = new ScoreKeeperContext())
            {
                //var score = new score { NAME = "test", POINTS = 2, GAMES = 1, LASTGAME = DateTime.Now };
                // db.scores.Add(score);
                //db.SaveChanges();

                var myParamName = new SqlParameter("@Name", SqlDbType.VarChar, 100);
                myParamName.Value = "tes";
                var myParamPoints = new SqlParameter("@Points", SqlDbType.Int, 4);
                myParamPoints.Value = 1;
                var myParamGames = new SqlParameter("@Games", SqlDbType.Int, 4);
                myParamGames.Value = 1;
                var myParamLastGame = new SqlParameter("@LastGame", SqlDbType.DateTime, 255);
                myParamLastGame.Value = DateTime.Now;

                var courseList = db.Database.ExecuteSqlCommand("exec InserUser @Name, @Points, @Games, @LastGame", myParamName, myParamPoints, myParamGames, myParamLastGame);

                var query = from b in db.scores select b;

                Console.WriteLine("All blogs in the database:");
                foreach (var item in query)
                {
                    Console.WriteLine(item.NAME);
                }
            }
        }
Esempio n. 2
0
 public void InputScoreSQL()
 {
     using (var db = new ScoreKeeperContext())
     {
         var query = from b in db.scores select b;
         foreach (var item in query)
         {
             ListUsers.Add(new User(item.NAME, item.POINTS, item.GAMES, item.LASTGAME));
         }
     }
 }
Esempio n. 3
0
        public void SaveScoreSQL(User user)
        {
            SqlParameter myParamName, myParamPoints, myParamGames, myParamLastGame;

            using (var db = new ScoreKeeperContext())
            {
                myParamName           = new SqlParameter("@Name", SqlDbType.VarChar, 100);
                myParamName.Value     = user.Name;
                myParamPoints         = new SqlParameter("@Points", SqlDbType.Int, 4);
                myParamPoints.Value   = user.Points;
                myParamGames          = new SqlParameter("@Games", SqlDbType.Int, 4);
                myParamGames.Value    = user.Games;
                myParamLastGame       = new SqlParameter("@LastGame", SqlDbType.DateTime, 255);
                myParamLastGame.Value = user.LastGame;

                db.Database.ExecuteSqlCommand("exec InserUser @Name, @Points, @Games, @LastGame", myParamName, myParamPoints, myParamGames, myParamLastGame);
            }
        }