|
1 | | -// Copyright (C) 2009-2020 Xtensive LLC. |
| 1 | +// Copyright (C) 2009-2021 Xtensive LLC. |
2 | 2 | // This code is distributed under MIT license terms. |
3 | 3 | // See the License.txt file in the project root for more information. |
4 | 4 | // Created by: Alexander Nikolaev |
@@ -37,6 +37,42 @@ public static PrefetchQuery<TElement> Prefetch<TElement, TFieldValue>( |
37 | 37 | return Prefetch(source, Session.Demand(), expression); |
38 | 38 | } |
39 | 39 |
|
| 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 | + |
| 55 | + /// <summary> |
| 56 | + /// Registers fields specified by <paramref name="expression"/> for prefetch. |
| 57 | + /// </summary> |
| 58 | + /// <typeparam name="TElement">The type of the element of the source sequence.</typeparam> |
| 59 | + /// <typeparam name="TFieldValue">The type of the field's value to be prefetched.</typeparam> |
| 60 | + /// <param name="source">The source query.</param> |
| 61 | + /// <param name="expression">The expression specifying a field to be prefetched.</param> |
| 62 | + /// <returns>An <see cref="IEnumerable{TElement}"/> of source items.</returns> |
| 63 | + public static PrefetchQuery<TElement> Prefetch<TElement, TFieldValue>( |
| 64 | + this QueryResult<TElement> source, |
| 65 | + Expression<Func<TElement, TFieldValue>> expression) |
| 66 | + { |
| 67 | + var session = source.Session; |
| 68 | + if (session != null) { |
| 69 | + return new PrefetchQuery<TElement>(session, source).RegisterPath(expression); |
| 70 | + } |
| 71 | + return new PrefetchQuery<TElement>(Session.Demand(), source).RegisterPath(expression); |
| 72 | + } |
| 73 | + |
| 74 | + |
| 75 | + |
40 | 76 | /// <summary> |
41 | 77 | /// Registers fields specified by <paramref name="expression"/> for prefetch. |
42 | 78 | /// </summary> |
|
0 commit comments