0

我有一个列表,我可以在其中选择一个项目。基于此项目的某些字段,我想过滤另一个控件中的选择列表。

像这样的东西:

Select * from choiceItems Where choiceItem.ID = (Select ID from anotherTable where anotherTable.ID = selectedItem.ID)

问题是可能有更多的 ID 返回。也许我想要 ID = {3,2,1} 等的所有选择项。

我无法在服务器上预处理查询,因为我的参数取决于列表中的选定项目。如果我尝试在查询编辑器中过滤结果,我只能指定只能是单个值的参数(fe ID=2)。

我如何在 Silverlight 中做到这一点?

另外,另一个不相关的小问题:是否可以在 lightswitch 中加载自定义控件时显示等待光标(现在它只显示灰色区域,直到加载数据和控件)。

4

3 回答 3

0

You should be able to preprocess the query even if the parameter for the query is selected from a list. You can then use LINQ to return a subset of your choiceItems or, based on the selected parameter, skip the LINQ which would return all of the choiceItems.

I give a detailed example of doing this in my answer to the SO question:

Is there a way to create a search screen in Lightswitch based on a dropdown

于 2012-08-23T15:32:46.703 回答
0

Select * from choiceItems Where choiceItem.ID = (Select ID from anotherTable where anotherTable.ID = selectedItem.ID)

这是一个多对多的场景,你需要使用查询参数制作一个 WCF RIA 服务,很多工作只是为了过滤。另一种方法是使这些表相关。

于 2012-08-22T14:23:32.213 回答
0

没有确切的语法,但应该是这样的:

首先使用 LINQ 获取 ID

var FilterOnThisId=this.Query1.Where(x=>x.ID==selectedItem.ID).FirstOrDefault();

然后查询你想要的colleciton

var filtedItems=this.Query2.Where(x=>x.ID==FilterOnThisId);
于 2014-06-17T20:05:35.613 回答