我正在制作一个 silverlight 5 应用程序并使用 RIA WCS 服务连接到 sql,我可以添加数据、删除数据、编辑数据并获取所有数据,但问题是我需要检索特定记录而不是整个实体,当我尝试以下代码时,什么也没发生:
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click ' InitializeComponent() objctx = New BanksDomainContext Dim itemType = Branch_NameComboBox.SelectedItem.GetType Dim pi = itemType.GetProperty(Branch_NameComboBox.DisplayMemberPath) Dim cbi = pi.GetValue(Branch_NameComboBox.SelectedItem, Nothing).ToString() Dim BranchName As String = cbi
' Dim query As EntityQuery(Of Branches) = objctx.GetBranchesDetailsQuery(BranchName)
' Dim loadOp As LoadOperation(Of Branches) = Me.objctx.Load(query)
' DataGrid1.ItemsSource = loadOp.Entities
' objctx.Load(query, LoadData, Nothing)
Dim loadOp = Me.objctx.Load(Me.objctx.GetBranchesDetailsQuery(BranchName))
LoadData(loadOp)
End Sub
Private Sub LoadData(lo As LoadOperation)
For Each br As Branches In lo.Entities
AddressTextBlock.Text = br.Address
CoordinatesTextBlock.Text = br.Coordinates
ManagerTextBlock.Text = br.Manager
PhoneTextBlock.Text = br.Phone
FaxTextBlock.Text = br.Fax
Next
End Sub
有人可以指导我怎么做吗?