EFIngresProvider/SqlGen/SqlGenerator/SqlGeneratorHelpers.cs
/// <summary>
/// Determine if the owner expression can add its unique sql to the input's
/// SqlSelectStatement
/// </summary>
/// <param name="result">The SqlSelectStatement of the input to the relational node.</param>
/// <param name="expressionKind">The kind of the expression node(not the input's)</param>
/// <returns></returns>
Determine if the owner expression can add its unique sql to the input's
SqlSelectStatement
Determine if the owner expression can add its unique sql to the input ' s SqlSelectStatement
private static bool IsCompatible(SqlSelectStatement result, DbExpressionKind expressionKind)
        {
            switch (expressionKind)
            {
                case DbExpressionKind.Distinct:
                    return result.Top.IsEmpty
                        && result.OrderBy.IsEmpty;
                case DbExpressionKind.Filter:
                    return result.Select.IsEmpty
                            && result.Where.IsEmpty
                            && result.GroupBy.IsEmpty
                            && result.Top.IsEmpty;
                case DbExpressionKind.GroupBy:
                    return result.Select.IsEmpty
                            && result.GroupBy.IsEmpty
                            && result.OrderBy.IsEmpty
                            && result.Top.IsEmpty;
                case DbExpressionKind.Limit:
                    return result.Top.TopCount == null;
                case DbExpressionKind.Element:
                    return result.Top.TopCount == null;
                case DbExpressionKind.Project:
                    return result.Select.IsEmpty
                            && result.GroupBy.IsEmpty
                            && !result.IsDistinct;
                case DbExpressionKind.Skip:
                    return result.Top.SkipCount == null;
                case DbExpressionKind.Sort:
                    return result.Select.IsEmpty
                            && result.GroupBy.IsEmpty
                            && result.OrderBy.IsEmpty
                            && !result.IsDistinct;
                default:
                    Debug.Assert(false);
                    throw new InvalidOperationException(String.Empty);
            }
        }
private static bool IsCompatible ( SqlSelectStatement result , DbExpressionKind expressionKind ) { switch ( expressionKind ) { case DbExpressionKind . Distinct : return result . Top . IsEmpty && result . OrderBy . IsEmpty ; case DbExpressionKind . Filter : return result . Select . IsEmpty && result . Where . IsEmpty && result . GroupBy . IsEmpty && result . Top . IsEmpty ; case DbExpressionKind . GroupBy : return result . Select . IsEmpty && result . GroupBy . IsEmpty && result . OrderBy . IsEmpty && result . Top . IsEmpty ; case DbExpressionKind . Limit : return result . Top . TopCount == null ; case DbExpressionKind . Element : return result . Top . TopCount == null ; case DbExpressionKind . Project : return result . Select . IsEmpty && result . GroupBy . IsEmpty && ! result . IsDistinct ; case DbExpressionKind . Skip : return result . Top . SkipCount == null ; case DbExpressionKind . Sort : return result . Select . IsEmpty && result . GroupBy . IsEmpty && result . OrderBy . IsEmpty && ! result . IsDistinct ; default : Debug . Assert ( false ) ; throw new InvalidOperationException ( String . Empty ) ; } }
Determine if the owner expression can add its unique sql to the input's
SqlSelectStatement
Determine if the owner expression can add its unique sql to the input ' s SqlSelectStatement
// The projection after distinct may not project all  // columns used in the Order By // Improvement: Consider getting rid of the Order By instead // Allow a Project to be compatible with an OrderBy // Otherwise we won't be able to sort an input, and project out only // a subset of the input columns // If distinct is specified, the projection may affect // the cardinality of the results, thus a new statement must be started. // A Project may be on the top of the Sort, and if so, it would need // to be in the same statement as the Sort (see comment above for the Project case). // A Distinct in the same statement would prevent that, and therefore if Distinct is present, // we need to start a new statement.  //return result.OrderBy.IsEmpty;
None
result
SqlSelectStatement
The SqlSelectStatement of the input to the relational node.
The SqlSelectStatement of the input to the relational node .
expressionKind
DbExpressionKind
The kind of the expression node(not the input's)
The kind of the expression node ( not the input ' s )