Select queries

Select queries can return content objects, properties values directly or calculated values. Here are a few examples:

A basic query for articles content objects:

var q = WAFContext.Session.CreateQuery();
q.From<ArticleBase>();
q.Select<ArticleBase>();
List<ArticleBase> articles = q.Execute<ArticleBase>();

 

A query for article names:

var q = WAFContext.Session.CreateQuery();
q.From<ArticleBase>();
q.Select(AqlArticleBase.Name);
List<string> articleNamess = q.Execute<string>();

 

Last, a query with a calculated select data. In this case the multiplication of node ids:

var q = WAFContext.Session.CreateQuery();
q.From<ArticleBase>();
q.Select(AqlArticleBase.NodeId * AqlArticleBase.NodeId);
q.Where(Aql.DateTimePart(AqlArticleBase.ReleaseDate, DateTimePart.Year) == 2010);
List<int> articleNodeIds= q.Execute<int>();

 

In the above example it is important to note that the expressions are converted to SQL, so the actual calculation and date part extraction is performed by the database engine.