コード例 #1
0
        internal static bool TryRewrite(
            DbQueryCommandTree tree,
            Span span,
            MergeOption mergeOption,
            AliasGenerator aliasGenerator,
            out DbExpression newQuery,
            out SpanIndex spanInfo)
        {
            newQuery = (DbExpression)null;
            spanInfo = (SpanIndex)null;
            ObjectSpanRewriter objectSpanRewriter = (ObjectSpanRewriter)null;
            bool flag = Span.RequiresRelationshipSpan(mergeOption);

            if (span != null && span.SpanList.Count > 0)
            {
                objectSpanRewriter = (ObjectSpanRewriter) new ObjectFullSpanRewriter((DbCommandTree)tree, tree.Query, span, aliasGenerator);
            }
            else if (flag)
            {
                objectSpanRewriter = new ObjectSpanRewriter((DbCommandTree)tree, tree.Query, aliasGenerator);
            }
            if (objectSpanRewriter != null)
            {
                objectSpanRewriter.RelationshipSpan = flag;
                newQuery = objectSpanRewriter.RewriteQuery();
                if (newQuery != null)
                {
                    spanInfo = objectSpanRewriter.SpanIndex;
                }
            }
            return(spanInfo != null);
        }
コード例 #2
0
 private void AddSpanMap(RowType rowType, Dictionary <int, AssociationEndMember> columnMap)
 {
     if (this._spanIndex == null)
     {
         this._spanIndex = new SpanIndex();
     }
     this._spanIndex.AddSpanMap(rowType, columnMap);
 }
コード例 #3
0
 private void AddSpannedRowType(RowType spannedType, TypeUsage originalType)
 {
     if (this._spanIndex == null)
     {
         this._spanIndex = new SpanIndex();
     }
     this._spanIndex.AddSpannedRowType(spannedType, originalType);
 }
コード例 #4
0
        private void AddSpanMap(RowType rowType, Dictionary <int, AssociationEndMember> columnMap)
        {
            if (null == _spanIndex)
            {
                _spanIndex = new SpanIndex();
            }

            _spanIndex.AddSpanMap(rowType, columnMap);
        }
コード例 #5
0
        private void AddSpannedRowType(RowType spannedType, TypeUsage originalType)
        {
            if (null == _spanIndex)
            {
                _spanIndex = new SpanIndex();
            }

            _spanIndex.AddSpannedRowType(spannedType, originalType);
        }
コード例 #6
0
        internal static bool TryRewrite(
            DbQueryCommandTree tree, Span span, MergeOption mergeOption, AliasGenerator aliasGenerator, out DbExpression newQuery,
            out SpanIndex spanInfo)
        {
            newQuery = null;
            spanInfo = null;

            ObjectSpanRewriter rewriter  = null;
            var requiresRelationshipSpan = Span.RequiresRelationshipSpan(mergeOption);

            // Potentially perform a rewrite for span.
            // Note that the public 'Span' property is NOT used to retrieve the Span instance
            // since this forces creation of a Span object that may not be required.
            if (span != null &&
                span.SpanList.Count > 0)
            {
                rewriter = new ObjectFullSpanRewriter(tree, tree.Query, span, aliasGenerator);
            }
            else if (requiresRelationshipSpan)
            {
                rewriter = new ObjectSpanRewriter(tree, tree.Query, aliasGenerator);
            }

            if (rewriter != null)
            {
                rewriter.RelationshipSpan = requiresRelationshipSpan;
                newQuery = rewriter.RewriteQuery();
                if (newQuery != null)
                {
                    Debug.Assert(
                        rewriter.SpanIndex != null || tree.Query.ResultType.EdmEquals(newQuery.ResultType),
                        "Query was rewritten for Span but no SpanIndex was created?");
                    spanInfo = rewriter.SpanIndex;
                }
            }

            return(spanInfo != null);
        }