首先是代码:
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
没有问题。我需要做些什么才能让它发挥作用?
答案 0 :(得分:0)
我想通了......在代码的前面,我有一个名为UserName的变量...所以我只是更改了它并且它有效。