HomeActive Query BuilderProgramatically set alias for an expression in the select list of a query

Programatically set alias for an expression in the select list of a query


Hi

Lets say I have this query
Select Price * Quantity From OrderDetails

How can I programatically provide an alias for the "Price * Quantity" expression using active query builder object model.

Thanks
Florin Iacob
Iacob Florin | email
September 30 2009, 06:47 AM
I forgot to mention that I'm using .Net version of the Active Query Builder.

Thanks
Florin Iacob
Iacob Florin | email
2 hours since original post
Meanwhile I solved this way (this is a simplified version of my code)

UnionSubQuery usq = queryBuilder1.Query.ActiveUnionSubquery;
for (int i = 0; i < usq.CriteriaList.Count; i++ )
{
CriteriaItem cItem = usq.CriteriaList[i];
cItem.AliasString = GenerateAlias();
}

What I realy wanted to do is to generate aliases for items that are expressions and only if the user did not specified an alias for that expression.

Is there an easy way to do this (like setting a property on Active Query Builder) ?

Thanks
Florin Iacob

Iacob Florin | email
21 hours, 55 mins since original post
Dear Iacob,

You may check the ExpressionField property of CriteriaItem object. This property is set to Null when item is a complex expression, not a single field.
Sergey Smagin | email
1 day, 23 hours since original post
This topic is closed