Developer Forum »
AqlExpressionBoolean | content.relation
5 posts

Is it possible to check if a content relation is set?

I want to do somthing like:

var exp = AqlSomeContent.SomeRelation.IsSet()

120 posts

I presume you want to check this in an AqlQuery, right?

 

(in code you've already shown how it can be done with your example)

 

It is possible to query relations in queries. Webnodes has in three types of relations, and each behave differently in queries. (read more here: http://developer.webnodes.com/relations)

For Node Relations, you can perform an inner join (left or outer join is not supported)

see here for more info: http://developer.webnodes.com/join-queries

(If you need to perform a count left or outer query, you can either do it in memory using LINQ to objects, or add a new integer field to the class that contains the number of related items, the property must be updated using custom code you add in the "OnBeforeUpdate" event in the content class partial code file in the "App_Code" or "Model" folder.)

Inner relations are not queryable in AQL (this is because).

 

Node parent are queryable in AQL. These properties are just integer fields directly on the class, and you do not need to perform a join. To check if a relation is set, simply filter for a value different from 0. (the value is the node id of the object you are relating to)

 

1