'新增按班级ID的查询方法
<Query(IsComposable:=False)>
Public Function Get学生表By班级ID(ByVal id As Integer) As IQueryable(Of 学生表)
Return Me.ObjectContext.学生表.Where(Function(x) CBool(x.班级ID = id))
End Function
Partial Public Class MainPage
Inherits UserControl
Private myD As New MyDomainContext
Public Sub New()
InitializeComponent()
SetCob()
SetDataGrid()
End Sub
Private Sub SetDataGrid()
Dim id As Integer = 0
If cob班级ID.SelectedValue Is Nothing = False Then
id = CInt(cob班级ID.SelectedValue)
End If
Dim loadop As LoadOperation(Of 学生表) = myD.Load(myD.Get学生表By班级IDQuery(id))
DataGrid1.ItemsSource = loadop.Entities()
End Sub
Private Sub SetCob()
Dim loadop As LoadOperation(Of 班级表) = myD.Load(myD.Get班级表Query())
cob班级ID.ItemsSource = loadop.Entities()
cob班级ID.DisplayMemberPath = "班级"
cob班级ID.SelectedValuePath = "班级ID"
End Sub
Private Sub cob班级ID_SelectionChanged(sender As Object, e As System.Windows.Controls.SelectionChangedEventArgs) Handles cob班级ID.SelectionChanged
SetDataGrid()
End Sub
End Class