Skip to content

Commit 006154b

Browse files
committed
Specific Prefetch extension for DelayedQuery{T}
Helps to get session and avoid using session activation
1 parent 9d947f3 commit 006154b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Orm/Xtensive.Orm/Orm/PrefetchExtensions.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2009-2020 Xtensive LLC.
1+
// Copyright (C) 2009-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: Alexander Nikolaev
@@ -37,6 +37,21 @@ public static PrefetchQuery<TElement> Prefetch<TElement, TFieldValue>(
3737
return Prefetch(source, Session.Demand(), expression);
3838
}
3939

40+
/// <summary>
41+
/// Registers fields specified by <paramref name="expression"/> for prefetch.
42+
/// </summary>
43+
/// <typeparam name="TElement">The type of the element of the source sequence.</typeparam>
44+
/// <typeparam name="TFieldValue">The type of the field's value to be prefetched.</typeparam>
45+
/// <param name="source">The source query.</param>
46+
/// <param name="expression">The expression specifying a field to be prefetched.</param>
47+
/// <returns>An <see cref="IEnumerable{TElement}"/> of source items.</returns>
48+
public static PrefetchQuery<TElement> Prefetch<TElement, TFieldValue>(
49+
this DelayedQuery<TElement> source,
50+
Expression<Func<TElement, TFieldValue>> expression)
51+
{
52+
return new PrefetchQuery<TElement>(source.Session, source).RegisterPath(expression);
53+
}
54+
4055
/// <summary>
4156
/// Registers fields specified by <paramref name="expression"/> for prefetch.
4257
/// </summary>

0 commit comments

Comments
 (0)