0

我正在为学校开发一个 VB 项目。这是一个蛇游戏,我将高分存储在数据库中。我需要知道如何从数据集中插入和删除记录,以便摆脱旧的低分并插入新的高分。我们在课堂上只简单地介绍了 LINQ,所以我一无所知。

这就是我到目前为止所拥有的,并且一切正常。

Private Sub HighScores_Load(sender As System.Object, e As System.EventArgs)
   Handles MyBase.Load

    'See if player score is higher than the low score, and if so, add player name and score to database

    Me.HighscoresTableAdapter.Fill(Me.VbprojectDataSet.highscores)

    Dim lowScore = Aggregate scores In VbprojectDataSet.highscores
                   Select scores.score
                   Into Min()

    If GridForm.player.score > lowScore Then

        Dim lowScoreRow = From scores In VbprojectDataSet.highscores
                          Where scores.score = lowScore
                          Select scores

        GridForm.player.name = InputBox("You got a new high score! What is your name?", "SnakE")

    End If

End Sub
4

1 回答 1

0

如果您使用Entity Framework,您可以保留样式,并且当您对实体对象进行更改时,LINQ您所要做的就是调用.Save.Enitity Container

实体框架教程

于 2013-05-03T21:09:17.147 回答