internal static QueryDef AndWhereRelated(this QueryDef query, BusinessObjectDef businessObjectDef, BusinessObjectDef relatedBusinessObjectDef, string relationshipName, string fieldName, CsmQueryOperator op, string value)
        {
            var cherWellOperator = OperatorMap[op];
            var cherWellTypedValue = TypedValue.ForString(value);

            var fieldDef = relatedBusinessObjectDef.Fields.GetFieldByDisplayNameOrName(fieldName);
            var relationshipDef = businessObjectDef.GetRelationshipDefByName(relationshipName);

            QueryConditionComparisonClause clauseAdditionalWhere = query.TopLevelGroupingClause.CreateFieldValueClause(fieldDef.FullId, cherWellOperator, cherWellTypedValue);
            QueryConditionClause clause = query.TopLevelGroupingClause.CreateRelatedClause(businessObjectDef.Id, relationshipDef.Id, RelatedBusObOccurrence.Any, 0, clauseAdditionalWhere);
            query.TopLevelGroupingClause.Clauses.Add(clause);

            return query;
        }
 internal static QueryDef OrWhere(this QueryDef query, BusinessObjectDef businessObjectDef, string fieldName, CsmQueryOperator op, DateTime value)
 {
     query.AndWhere(businessObjectDef, fieldName, op, value);
     query.TopLevelGroupingClause.OrClauses = true;
     return query;
 }
 internal static QueryDef AndWhere(this QueryDef query, BusinessObjectDef businessObjectDef, string fieldName, CsmQueryOperator op)
 {
     var cherWellTypedValue = TypedValue.AlwaysBlank;
     return GetQuery(query, businessObjectDef, fieldName, op, cherWellTypedValue);
 }
 internal static QueryDef AndWhere(this QueryDef query, BusinessObjectDef businessObjectDef, string fieldName, CsmQueryOperator op, DateTime value)
 {
     var cherWellTypedValue = TypedValue.ForDateTime(value);
     return GetQuery(query, businessObjectDef, fieldName, op, cherWellTypedValue);
 }
        private static QueryDef GetQuery(QueryDef query, BusinessObjectDef businessObjectDef, string fieldName, CsmQueryOperator op, TypedValue value)
        {
            var cherWellOperator = OperatorMap[op];
            var fieldDef = businessObjectDef.Fields.GetFieldByDisplayNameOrName(fieldName);
            QueryConditionClause clause = query.TopLevelGroupingClause.CreateFieldValueClause(fieldDef.Id, cherWellOperator, value);
            query.TopLevelGroupingClause.Clauses.Add(clause);

            return query;
        }