コード例 #1
0
 public void ClearScores()
 {
     using (var context = new ReversiContext())
     {
         context.Database.ExecuteSqlCommand("DELETE FROM Scores");
     }
 }
コード例 #2
0
 public void DeleteComment()
 {
     using (var context = new ReversiContext())
     {
         context.Database.ExecuteSqlCommand("DELETE FROM Comments");
     }
 }
コード例 #3
0
 public void AddScore(Score score)
 {
     using (var context = new ReversiContext())
     {
         context.Scores.Add(score);
         context.SaveChanges();
     }
 }
コード例 #4
0
 public void AddComment(Comment comment)
 {
     using (var context = new ReversiContext())
     {
         context.Add(comment);
         context.SaveChanges();
     }
 }
コード例 #5
0
 public int GetRating()
 {
     using (var context = new ReversiContext())
     {
         // return context.Database.ExecuteSqlCommand("SELECT AVG(rating) FROM Rating ");
         int a = (int)(from s in context.Ratings select s.rating).Average();
         return(a);
     }
 }
コード例 #6
0
        public void AddRating(Rating rating)
        {
            using (var context = new ReversiContext())
            {
                context.Add(rating);

                context.SaveChanges();
            }
        }
コード例 #7
0
 public List <Score> GetTopScores()
 {
     using (var context = new ReversiContext())
     {
         return((from s in context.Scores
                 orderby s.Points
                 descending
                 select s).Take(5).ToList());
     }
 }
コード例 #8
0
        public List <Comment> GetComments()

        {
            using (var context = new ReversiContext())
            {
                //context.Database.ExecuteSqlCommand("SELECT * FROM Comments");
                return((from s in context.Comments
                        orderby s.Coment

                        select s).ToList());
            }
        }