コード例 #1
0
        public static Query AddLastTableSourceAlias(this Query query, string alias)
        {
            Argument.NotNull(query, "query");
            Argument.NotWhiteSpace(alias, "alias");
            var lastTableSource = query.From.InternalNodes.LastOrDefault();

            if (lastTableSource == null)
            {
                throw new InvalidOperationException("Query's table source list is empty.");
            }
            var lastItem = lastTableSource as SimpleTableSource;

            if (lastItem == null)
            {
                throw new InvalidOperationException("An alias couldn't be added to the last query's table source.");
            }
            if (lastItem.Alias != null)
            {
                throw new InvalidOperationException("Last table source already has an alias.");
            }
            var newTableSource = new SimpleTableSource(lastItem.Table, alias);

            return(new Query(query.Select, query.From.ReplaceLast(newTableSource), query.Where));
        }
コード例 #2
0
 protected internal virtual void VisitSimpleTableSource(SimpleTableSource tableSource)
 {
 }