首先是代码:
Dim tCards = (From r In myDB.CAH_TableCards Join c In myDB.CAH_Cards On r.CardId Equals c.CardId Where r.GameId = oGame.GameId And r.Round = oGame.Round Select c).SingleOrDefault
Dim pCards = From r In myDB.CAH_PlayerCards Join c In myDB.CAH_Cards On r.CardID Equals c.CardId Where r.GameId = oGame.GameId And r.username = UserName Select c
Dim rcards As List(Of TableCard) = From z In myDB.CAH_RoundCards Join c In myDB.CAH_Cards On z.CardId Equals c.CardId Where z.GameId = oGame.GameId And z.Round = oGame.Round Select c.CardId, c.CardType, c.Text, c.Answers, c.SetId, c.Added, z.Username, z.Visible
现在上课:
Imports Microsoft.VisualBasic
Public Class TableCard
Public CardId As Integer
Public CardType As Integer
Public Text As String
Public Answers As Integer
Public SetId As Integer
Public Added As Date
Public Visible As Boolean
Public Username As String
End Class
最后这个问题:
官方错误是
BC30978:范围变量“用户名”隐藏封闭块中的变量或先前在查询表达式中定义的范围变量。
在研究了错误后,我想出了 zip、zilch、nada。现在错误直到我添加z.username
到最后才发生。在此之前它工作得很好。该Username
字段是该表中的有效字段。我已经CAH_RoundCards
在代码的其他部分使用没有问题。我需要做什么才能使其正常工作?