예제 #1
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;
            bool 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);
        }
        internal static string GetColumnMapKey(ColumnMap columnMap, SpanIndex spanIndex)
        {
            ColumnMapKeyBuilder columnMapKeyBuilder = new ColumnMapKeyBuilder(spanIndex);

            columnMap.Accept <int>((ColumnMapVisitor <int>)columnMapKeyBuilder, 0);
            return(columnMapKeyBuilder._builder.ToString());
        }
예제 #3
0
        // <summary>
        // Returns a string uniquely identifying the given ColumnMap.
        // </summary>
        internal static string GetColumnMapKey(ColumnMap columnMap, SpanIndex spanIndex)
        {
            var builder = new ColumnMapKeyBuilder(spanIndex);

            columnMap.Accept(builder, 0);
            return(builder._builder.ToString());
        }
        /// <summary>
        /// Moves forward by one char or one classification span
        /// </summary>
        /// <returns>true, if moved</returns>
        public override bool MoveNext()
        {
            if (!AtEnd())
            {
                //operators are processed char by char, because the classifier can merge several operators into one span (like "]]", "[]")
                CurrentPoint = CurrentSpan != null && CurrentSpan.ClassificationType.Classification != "punctuation" ? CurrentSpan.Span.End : CurrentPoint + 1;

                if (SpanIndex.ContainsKey(CurrentPoint.Position))
                {
                    CurrentSpan = SpanIndex[CurrentPoint.Position];
                }
                else
                {
                    if (CurrentSpan != null && CurrentPoint.Position >= CurrentSpan.Span.End.Position) //we're out of current span
                    {
                        CurrentSpan = null;
                    }
                }
                return(true);
            }
            return(false);
        }
예제 #5
0
        private void AddSpanMap(RowType rowType, Dictionary<int, AssociationEndMember> columnMap)
        {
            if (null == _spanIndex)
            {
                _spanIndex = new SpanIndex();
            }

            _spanIndex.AddSpanMap(rowType, columnMap);
        }
예제 #6
0
        private void AddSpannedRowType(RowType spannedType, TypeUsage originalType)
        {
            if (null == _spanIndex)
            {
                _spanIndex = new SpanIndex();
            }

            _spanIndex.AddSpannedRowType(spannedType, originalType);
        }
예제 #7
0
 private ColumnMapKeyBuilder(SpanIndex spanIndex)
 {
     _spanIndex = spanIndex;
 }
 internal override ShaperFactory TypedCreate(QueryCacheManager cacheManager, ColumnMap columnMap, MetadataWorkspace metadata, SpanIndex spanInfo, MergeOption mergeOption, bool valueLayer)
 {
     return(Translator.TranslateColumnMap <T>(cacheManager, columnMap, metadata, spanInfo, mergeOption, valueLayer));
 }
 internal abstract ShaperFactory TypedCreate(QueryCacheManager cacheManager, ColumnMap columnMap, MetadataWorkspace metadata, SpanIndex spanInfo, MergeOption mergeOption, bool valueLayer);
        internal static ShaperFactory Create(Type elementType, QueryCacheManager cacheManager, ColumnMap columnMap, MetadataWorkspace metadata, SpanIndex spanInfo, MergeOption mergeOption, bool valueLayer)
        {
            ShaperFactoryCreator creator = (ShaperFactoryCreator)Activator.CreateInstance(typeof(TypedShaperFactoryCreator <>).MakeGenericType(elementType));

            return(creator.TypedCreate(cacheManager, columnMap, metadata, spanInfo, mergeOption, valueLayer));
        }