/// <summary> /// Typeds the type of the values for operator column. /// </summary> /// <param name="typedValues">The typed values.</param> /// <param name="conditionType">Type of the condition.</param> /// <param name="columnType">Type of the column.</param> /// <returns>IList{TypedValue}.</returns> private static IList <TypedValue> TypedValuesForOperatorColumnType(IEnumerable <TypedValue> typedValues, ConditionType conditionType, DatabaseType columnType) { IList <TypedValue> values = new List <TypedValue>(); if (typedValues == null) { return(values); } foreach (TypedValue typedValue in typedValues) { int operatorCount = ConditionTypeHelper.GetArgumentCount(conditionType); if (operatorCount <= 0) { continue; } DatabaseType type = ConditionTypeHelper.GetArgumentType(conditionType, columnType, operatorCount - 1); if (type != null) { typedValue.Type = type; values.Add(typedValue); } } return(values); }
/// <summary> /// Applies the analyser conditions. /// </summary> /// <param name="structuredQuery">The structured query.</param> /// <param name="selectedColumnConditions">The selected column conditions.</param> private static void ApplyAnalyserConditions(StructuredQuery structuredQuery, IEnumerable <SelectedColumnCondition> selectedColumnConditions) { foreach (SelectedColumnCondition columnCondition in selectedColumnConditions) { QueryCondition queryCondition = structuredQuery.Conditions.FirstOrDefault(sqc => sqc.EntityId.ToString(CultureInfo.InvariantCulture) == columnCondition.ExpressionId); if (columnCondition.ExpressionId == "_id") { queryCondition = new QueryCondition( ); queryCondition.Expression = new IdExpression { NodeId = structuredQuery.RootEntity.NodeId }; structuredQuery.Conditions.Add(queryCondition); } if (queryCondition == null) { // Adhoc condition for column SelectColumn column = structuredQuery.SelectColumns.FirstOrDefault(sqc => sqc.EntityId.ToString(CultureInfo.InvariantCulture) == columnCondition.ExpressionId); if (column == null) { continue; } queryCondition = new QueryCondition(); queryCondition.Argument = new TypedValue(); queryCondition.Argument.Type = columnCondition.Type; queryCondition.Expression = new ColumnReference { ColumnId = column.ColumnId }; structuredQuery.Conditions.Add(queryCondition); } if (columnCondition.EntityIdentifiers != null && columnCondition.EntityIdentifiers.Count > 0) { queryCondition.Operator = columnCondition.Operator; long sourceId = queryCondition.Argument.SourceEntityTypeId; DatabaseType type = ConditionTypeHelper.GetArgumentType(columnCondition.Operator, queryCondition.Argument.Type); queryCondition.Arguments.Clear(); var isStructureLevelOperator = ConditionTypeHelper.IsStructureLevelOperator(queryCondition.Operator); foreach (long filterEntityId in columnCondition.EntityIdentifiers) { object value; if (isStructureLevelOperator && type is StringType) { value = filterEntityId.ToString(); } else { value = filterEntityId; } queryCondition.Arguments.Add(new TypedValue { Type = type, SourceEntityTypeId = sourceId, Value = value }); } } else { queryCondition.Operator = columnCondition.Operator; if (queryCondition.Argument != null) { if (columnCondition.Type != null) { DatabaseType argType = queryCondition.Argument.Type is UnknownType ? columnCondition.Type : queryCondition.Argument.Type; queryCondition.Argument.Type = ConditionTypeHelper.GetArgumentType(columnCondition.Operator, argType); } queryCondition.Argument.Value = columnCondition.Value; } } } }