Skip to content

Commit 31902fe

Browse files
authored
Merge pull request #144 from DataObjects-NET/master-prefetch-graph-issue
Fixes prefetch graph building issue
2 parents e67adc3 + 9a0a07e commit 31902fe

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

Orm/Xtensive.Orm/Orm/Internals/Prefetch/Nodes/ExpressionMapBuilder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2012 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2012-2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Denis Krjuchkov
55
// Created: 2012.02.24
66

@@ -63,7 +63,7 @@ protected override Expression VisitMethodCall(MethodCallExpression call)
6363
// All lambdas will be associated with single parent.
6464
call = (MethodCallExpression) source;
6565
ValidateMethodCall(call);
66-
source = call.Arguments[0];
66+
source = call.Arguments[0].StripCasts();
6767
var lambda = call.Arguments[1].StripQuotes();
6868
subprefetches.Add(lambda);
6969
}

Orm/Xtensive.Orm/Orm/Internals/Prefetch/PrefetchQueryEnumerable.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2010-2020 Xtensive LLC.
1+
// Copyright (C) 2010-2021 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Alexis Kochetov
@@ -125,13 +125,6 @@ private StrongReferenceContainer ProcessFetchedElements(Guid enumerationId)
125125
return container;
126126
}
127127

128-
//private void Initialize()
129-
//{
130-
// unknownTypeQueue = new Queue<Key>();
131-
// prefetchQueue = new Queue<Pair<IEnumerable<Key>, IHasNestedNodes>>();
132-
// fieldDescriptorCache = new Dictionary<Pair<IHasNestedNodes, TypeInfo>, IList<PrefetchFieldDescriptor>>();
133-
//}
134-
135128
public PrefetchQueryEnumerable(Session session, IEnumerable<TItem> source,
136129
SinglyLinkedList<KeyExtractorNode<TItem>> nodes)
137130
{

Orm/Xtensive.Orm/Orm/PrefetchExtensions.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ public static PrefetchQuery<TElement> Prefetch<TElement, TFieldValue>(
9292
return Prefetch(source, Session.Demand(), expression);
9393
}
9494

95+
/// <summary>
96+
/// Registers fields specified by <paramref name="expression"/> for prefetch.
97+
/// </summary>
98+
/// <typeparam name="TElement">The type of the element of the source sequence.</typeparam>
99+
/// <typeparam name="TFieldValue">The type of the field's value to be prefetched.</typeparam>
100+
/// <param name="source">The source sequence.</param>
101+
/// <param name="expression">The expression specifying a field to be prefetched.</param>
102+
/// <returns>An <see cref="IEnumerable{TElement}"/> of source items.</returns>
103+
public static PrefetchQuery<TElement> Prefetch<TElement, TFieldValue>(
104+
this PrefetchQuery<TElement> source,
105+
Expression<Func<TElement, TFieldValue>> expression)
106+
{
107+
return source.RegisterPath(expression);
108+
}
109+
95110
/// <summary>
96111
/// Creates <see cref="PrefetchQuery{T}"/> for the specified <paramref name="source"/> and
97112
/// registers the prefetch of the field specified by <paramref name="expression"/>.

0 commit comments

Comments
 (0)