【发布时间】:2015-04-28 13:17:43
【问题描述】:
partial void Query1_PreprocessQuery(string Filter1, ref IQueryable<Type> query)
{
//how can I loop through the query and add data to a custom list
}
【问题讨论】:
标签: iqueryable lightswitch-2013
partial void Query1_PreprocessQuery(string Filter1, ref IQueryable<Type> query)
{
//how can I loop through the query and add data to a custom list
}
【问题讨论】:
标签: iqueryable lightswitch-2013
一般来说,_PreprocessQuery 方法用于定义查询的内容,而不是对这些内容做任何事情(这将是后期处理)。所以一个简单的方法可能是:
partial void Query1_PreprocessQuery(string Filter1, ref IQueryable<Type> query)
{
query = query.Where(x => x.FilterColumn == Filter1);
}
这发生在服务器端,因此即使您确实拦截了结果,我认为将您创建的任何列表返回到客户端也会很棘手。
一旦查询结果被传递到客户端屏幕,您就可以循环查询并使用您喜欢的内容,例如使用 Query1_Loaded 之类的屏幕属性方法或 Query1_Changed 之类的集合方法,具体取决于您正在尝试的内容实现。未经测试的代码,但类似这样:
partial void Query1_Loaded(bool succeeded)
{
// Loop through the rows on the screen ...
foreach (IEntityObject rowData in this.Query1)
{
// Reference individual values like this ...
string FilterResult = rowData.Details.Properties["FilterColumn"].Value.ToString()
}
}
}
【讨论】: