private void getCustomerOrders_Click(object sender, RoutedEventArgs e) { // Instantiate the data service context and clear any existing bindings. ResetBindingData(); // Define the filter condition based on the customer ID. string filterExpression = "CustomerID eq'" + this.customerId.Text + "'"; // Define a query to return the specifed customer and related orders. //根据查询条件先查询Customers表的信息,然后在查询与之关联的Orders表 DataServiceQuery<Customers> query = svsContext.Customers.AddQueryOption("$filter", filterExpression).Expand("Orders"); try { // Begin the query execution. query.BeginExecute(OnCustomerOrdersQueryComplete, query); } catch (Exception ex) { messageTextBlock.Text = ex.Message; } }
