Skip to content

Commit 8d350e8

Browse files
committed
Dedicated prefetch extension for PrefetchQuery<T>
This help to avoid casts in expression
1 parent fab738d commit 8d350e8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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)