从代码中调用数据实体查询 [英] Calling data entity queries from code

查看:88
本文介绍了从代码中调用数据实体查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户查找网格,我需要使用该查询网格填充数据实体上的查询结果(例如,Customers).我在客户"实体上有三个不同的查询,具体取决于从自动完成组合框中选择的用户 希望使用三个不同查询之一的结果填充网格.我似乎无法明白这一点.有什么建议吗?

I have a customer lookup grid that I need to populate with the results of a query on a data entity (say Customers).  I have three different queries on the Customers entity and depending on the selection of the user from an auto complete combo box I want to populate the grid with the results of one of the three different queries.  I cant seem to get this.  Any suggestions?

这是我最近的尝试的一个片段:

Here is a snipped from my latest attempt:

      局部无效的ActiveChoice_Changed()            nbsp; ;              nbsp; b ;    //用户的组合框选择
       {
          如果(this.ActiveChoice ==所有")
           {
                             DataWorkspace.JobData.SortedByName().Execute();
                             this.Refresh();
           }
          如果(this.ActiveChoice ==活动")
           {
                             DataWorkspace.JobData.ActiveOnly().Execute();
                             this.Refresh();
           }
          如果(this.ActiveChoice =="NotActive")
           {
                             DataWorkspace.JobData.NotActive().Execute();
                             this.Refresh();
           }
       }

        partial void ActiveChoice_Changed()                                                    //combo box choice from user
        {
            if (this.ActiveChoice == "All")
            {
                DataWorkspace.JobData.SortedByName().Execute();
                this.Refresh();
            }
            if (this.ActiveChoice == "Active")
            {
                DataWorkspace.JobData.ActiveOnly().Execute();
                this.Refresh();
            }
            if (this.ActiveChoice == "NotActive")
            {
                DataWorkspace.JobData.NotActive().Execute();
                this.Refresh();
            }
        }

刷新后,无论选择什么记录,所有记录都会显示出来??

After refresh all records are displayed regardless of what is chosen????

推荐答案

如果有一个记录会更好查询并将activeChoice参数传递给查询.看看这个链接并观看视频

It would be better if you have one query and pass an activeChoice parameter to the query. Take a look at this link and watch the video

 

http://msdn.microsoft.com/en-us/library/ff851973.aspx

http://msdn.microsoft.com/en-us/library/ff851973.aspx


这篇关于从代码中调用数据实体查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆