Esempio n. 1
0
        public static Query AddLastProjectionAlias(this Query query, string alias)
        {
            Argument.NotNull(query, "query");
            Argument.NotWhiteSpace(alias, "alias");
            var lastProjection = query.Select.InternalNodes.LastOrDefault();

            if (lastProjection == null)
            {
                throw new InvalidOperationException("Query's select list is empty.");
            }
            var lastItem = lastProjection as ColumnProjection;

            if (lastItem == null)
            {
                throw new InvalidOperationException("Unknown projection type.");
            }
            if (lastItem.Alias != null)
            {
                throw new InvalidOperationException("Last projection already has an alias.");
            }
            var newItem = new ColumnProjection(lastItem.Column, alias);

            return(new Query(query.Select.ReplaceLast(newItem), query.From, query.Where));
        }
Esempio n. 2
0
 protected internal virtual void VisitColumnProjection(ColumnProjection item)
 {
 }