예제 #1
0
        /// <summary>
        /// 访问 <see cref="OuterJoinedExpression"/>。
        /// </summary>
        /// <param name="outer">要访问的表达式。</param>
        /// <returns></returns>
        protected virtual Expression VisitOuterJoined(OuterJoinedExpression outer)
        {
            var test       = Visit(outer.Test);
            var expression = Visit(outer.Expression);

            return(outer.Update(test, expression));
        }
예제 #2
0
        internal static ProjectionExpression AddOuterJoinTest(this ProjectionExpression proj, string name = null)
        {
            var test   = GetOuterJoinTest(proj.Select);
            var select = proj.Select;
            ColumnExpression testCol = null;

            // look to see if test expression exists in columns already
            foreach (var col in select.Columns)
            {
                if (test.Equals(col.Expression))
                {
                    testCol = new ColumnExpression(test.Type, select.Alias, col.Name, null);
                    break;
                }
            }
            if (testCol == null)
            {
                // add expression to projection
                testCol = test as ColumnExpression;
                string colName = (testCol != null) ? testCol.Name : "Test";
                colName = proj.Select.Columns.GetAvailableColumnName(colName);
                select  = select.AddColumn(new ColumnDeclaration(colName, test));
                testCol = new ColumnExpression(test.Type, select.Alias, colName, null);
            }
            var newProjector = new OuterJoinedExpression(testCol, proj.Projector);

            return(new ProjectionExpression(select, newProjector, proj.Aggregator));
        }