任何人都可以看到我不能做的简单错误吗?
我打开一个表单,允许将作业编号分配给没有任何发票的发票。
这是处理此问题的应用程序主窗体中的代码:
Dim unknownJobs = From pur In context.Purchases
Where pur.SentToMyob = False AndAlso
pur.Job.JobNumber = String.Empty
Select pur
If unknownJobs.Any Then
frmJobs2.JobsBindingSource.DataSource = (From j In context.Jobs1
Order By j.JobNumber
Select j).ToList
frmJobs2.PurchasesBindingSource.DataSource = unknownJobs
Progress.Hide()
If frmJobs2.ShowDialog = Windows.Forms.DialogResult.OK Then
context.SaveChanges()
End If
End If
这是打开的表单,其中显示了相关的列详细信息
背后的守则很简单,包括:
Public Class FormJobs2
''' <summary>
''' OK clicked
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub OKButton_Click(sender As System.Object, e As System.EventArgs) Handles OKButton.Click
Me.DialogResult = Windows.Forms.DialogResult.OK
Me.Close()
End Sub
''' <summary>
''' Cancel clicked
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub SkipButton_Click(sender As System.Object, e As System.EventArgs) Handles SkipButton.Click
Me.DialogResult = Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
End Class
运行时会发生的情况是您可以选择作业编号,但它们不会显示在DataGridView上,也不会更新基础上下文。
请问愚蠢的错误在哪里?
答案 0 :(得分:1)
您似乎正在尝试为frmJobs2.PurchasesBindingSource.DataSource
分配IQueryable。
该行应为:
frmJobs2.PurchasesBindingSource.DataSource = unknownJobs.ToList