NonQualifiedNameNames in v126.96.36.1994
I have a known column name, and want to find the object in the query that corresponds to that name. The name I have is not qualified but it is qualified in the sql. E.g. I have "Color" and the column in the select is "Product.Color"
I have the QueryColumnListItem-s from the select query, and want to get the unqualified name. In the past I used
CriteriaItem crit = ...
(crit.Expression as SQLExpressionColumn)?.Column?.NonQualifiedNameNames
In v3 I have
QueryColumnListItem crit = ...
//NonQualifiedNameNames doesn't exist, not sure how to use
//(crit.Expression as SQLExpressionColumn).Column.BuildNonQualifiedNameNames
SQLObjectColumn col = (crit.Expression as SQLExpressionColumn)?.Column;
var foo = col?.Items?.FirstOrDefault() as AstToken;
foo?.Token //contains "Color"
I worry this is a bit of a hack and won't work in some circumstances, is there a better way?
The best way to find database object and field by column name is to use the QueryBuilder.QueryStatistics.OutputColumns collection. Each item of this collection has references to MetadataObject, MetadataField and QueryColumnListItem (former CriteriaItem). What you need to get in result?