Beispiel #1
0
            public static HashSet <ColumnExpression> Gather(HashSet <TableAlias> aliases, SelectExpression select)
            {
                var gatherer = new JoinColumnGatherer(aliases);

                gatherer.Gather(select.Where);
                return(gatherer.columns);
            }
Beispiel #2
0
        /// <summary>
        /// Gets an expression that be used by a query to determines if an outer join had a successful match
        /// (as opposed to null columns when no match occurs).
        /// </summary>
        public virtual Expression GetOuterJoinTest(SelectExpression select)
        {
            // if the column is used in the join condition (equality test)
            // if it is null in the database then the join test won't match (null != null) so the row won't appear
            // we can safely use this existing column as our test to determine if the outer join produced a row

            // find a column that is used in equality test
            var aliases     = DeclaredAliasGatherer.Gather(select.From);
            var joinColumns = JoinColumnGatherer.Gather(aliases, select).ToList();

            if (joinColumns.Count > 0)
            {
                // prefer one that is already in the projection list.
                foreach (var jc in joinColumns)
                {
                    foreach (var col in select.Columns)
                    {
                        if (jc.Equals(col.Expression))
                        {
                            return(jc);
                        }
                    }
                }
                return(joinColumns[0]);
            }

            // fall back to introducing a constant
            return(Expression.Constant(1, typeof(int?)));
        }
            public static HashSet <DbColumnExpression> Gather(HashSet <TableAlias> aliases, DbSelectExpression select)
            {
                var gatherer = new JoinColumnGatherer(aliases);

                if (gatherer != null)
                {
                    gatherer.Gather(select.Where);
                }

                return(gatherer.columns);
            }
Beispiel #4
0
        public virtual Expression GetOuterJoinTest(SelectExpression select)
        {
            List <ColumnExpression> list = JoinColumnGatherer.Gather(DeclaredAliasGatherer.Gather(select.From), select).ToList <ColumnExpression>();

            if (list.Count > 0)
            {
                foreach (ColumnExpression expression in list)
                {
                    foreach (ColumnDeclaration declaration in select.Columns)
                    {
                        if (expression.Equals(declaration.Expression))
                        {
                            return(expression);
                        }
                    }
                }
                return(list[0]);
            }
            return(Expression.Constant(1, typeof(int?)));
        }
        internal virtual Expression GetOuterJoinTest(DbSelectExpression select)
        {
            var aliases     = DbDeclaredAliasGatherer.Gather(select.From);
            var joinColumns = JoinColumnGatherer.Gather(aliases, select).ToList();

            if (joinColumns.Count > 0)
            {
                foreach (var jc in joinColumns)
                {
                    foreach (var col in select.Columns)
                    {
                        if (jc.Equals(col.Expression))
                        {
                            return(jc);
                        }
                    }
                }

                return(joinColumns[0]);
            }

            return(Expression.Constant(1, typeof(int?)));
        }
        Expression GetOuterJoinTest(SelectExpression select)
        {
            var aliases     = TableAliasGatherer.Gather(select.From);
            var joinColumns = JoinColumnGatherer.Gather(aliases, select).ToList();

            if (joinColumns.Count > 0)
            {
                // prefer one that is already in the projection list.
                foreach (var jc in joinColumns)
                {
                    foreach (var col in select.Columns)
                    {
                        if (jc.Equals(col.Expression))
                        {
                            return(jc);
                        }
                    }
                }
                return(joinColumns[0]);
            }

            // fall back to introducing a constant
            return(Expression.Constant(1, typeof(int?)));
        }
 public static HashSet<ColumnExpression> Gather(HashSet<TableAlias> aliases, SelectExpression select)
 {
     var gatherer = new JoinColumnGatherer(aliases);
     gatherer.Gather(select.Where);
     return gatherer.columns;
 }