【发布时间】:2013-04-01 08:49:50
【问题描述】:
我正在尝试执行自定义 K2 智能对象的 Get List 方法,该方法查询 SQL 数据库对象(视图)。我在现有的 C# 项目中使用 API 来执行这些智能对象。我想将多个过滤器传递给这个 GetList 方法。
我正在使用下面的代码添加单个过滤器,但无法找到传递多个过滤器的方法:
Dictionary<string, string>[] results = null;
if (!server.Connection.IsConnected) return results;
SmartObject smartObject = server.GetSmartObject(objectName);
SmartListMethod newList = smartObject.ListMethods["GetList"];
smartObject.MethodToExecute = methodName;
Contains myFilter = new Contains();
myFilter.Left = new PropertyExpression(filterPropertyName, PropertyType.Text);
myFilter.Right = new ValueExpression(filterValue, PropertyType.Text);
newList.Filter = myFilter;
SmartObjectList list = server.ExecuteList(smartObject);
results = new Dictionary<string, string>[list.SmartObjectsList.Count];
for (int i = 0; i < list.SmartObjectsList.Count; i++)
{
results[i] = new Dictionary<string, string>();
SmartObject smo = list.SmartObjectsList[i];
foreach (SmartProperty property in smo.Properties)
{
results[i].Add(property.Name, property.Value);
}
}
return results;
就像上面代码中的myFilter,我想传递多个这样的过滤器。
【问题讨论】:
-
找到解决方案,需要使用AND/OR逻辑过滤器来组合其他过滤器,如包含和等于。
-
只是想添加一个注释,其中包含如何为他人执行此操作的代码(以及我自己在睡了几晚之后又忘记了)。感谢您的回答!
标签: k2