导航

测试日志2

Posted on 2010-07-15 00:13  nowell  阅读(139)  评论(0)    收藏  举报

先主要测试一下几点:

1、博文是否能发布到我在博客园上的博客中

2、粘帖过来的代码,是否能在博客中高亮显示

以下的代码是通过image 按钮插入的。

private void ResetBindingData()
        {
            //Create a new data service context
            svsContext = new NorthwindEntities(new Uri("Northwind.svc", UriKind.Relative));
            ordersBindingCollection.Clear();
            detailsBindingCollection.Clear();
        }
        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;
            }
        }

以下的代码是通过image 按钮插入的。

private void OnCustomerOrdersQueryComplete(IAsyncResult result)
        {
            // Use the Dispatcher to ensure that the 
            // asynchronous call returns in the correct thread.
            Dispatcher.BeginInvoke(() =>
                {
                    // Get the original query back from the result.
                    DataServiceQuery<Customers> query = result.AsyncState as DataServiceQuery<Customers>;
                    try
                    {
                        Customers returnedCustomer = query.EndExecute(result).FirstOrDefault();
                        if (returnedCustomer != null)
                        {
                            // Load the retuned orders into the binding collection.
                            foreach (Orders order in returnedCustomer.Orders)
                            {
                                ordersBindingCollection.Add(order);
                            }
                            // Bind the grid control to the collection and update the layout
                            this.ordersGrid.DataContext = ordersBindingCollection;
                            this.ordersGrid.UpdateLayout();
                            // Hide the relationship property columns.
                            //this.ordersGrid.Columns[8].Visibility = Visibility.Collapsed;
                            //this.ordersGrid.Columns[11].Visibility = Visibility.Collapsed;
                            this.ordersGrid.Columns[15].Visibility = Visibility.Collapsed;
                        }
                    }
                    catch (DataServiceQueryException ex)
                    {
                        this.messageTextBlock.Text = string.Format("Error: {0}-{1}",ex.Response.StatusCode.ToString(),ex.Response.Error.Message);
                        throw;
                    }
                }
            );

        }

测试完工.

再说点题外话,今天被03系统不能直接安装windows live writer程序的问题折腾了一晚上,太郁闷了,最终还是在下载吧找了个绿色版的windows live writer,才解决的问题!自己的技术博客终于整理好了,从明天开始就要书写程序人生了!

友荐云推荐