public TValue Load() { lock (_lock) { return(_inner.Load()); } }
public virtual void Intercept(IInvocation invocation) { var methodName = invocation.Method.Name; if (_lazyLoaderGetter.Equals(invocation.Method)) { invocation.ReturnValue = _loader; } else if (_lazyLoaderSetter.Equals(invocation.Method)) { _loader = (ILazyLoader)invocation.Arguments[0]; } else { if (_loader != null && methodName.StartsWith("get_", StringComparison.Ordinal)) { var navigationName = methodName.Substring(4); var navigation = _entityType.FindNavigation(navigationName); if (navigation != null) { _loader.Load(invocation.Proxy, navigationName); } } invocation.Proceed(); } }
public T GetResult() { if (!IsCompleted) { _result = LazyLoader.Load(); IsCompleted = true; } return(_result); }
/// <inheritdoc /> public T Load() { if (!_loaded) { _value = _inner.Load(); _loaded = true; } return(_value); }
/// <summary> /// Loads a navigation property if it has not already been loaded. /// </summary> /// <remarks> /// See <see href="https://aka.ms/efcore-docs-lazy-loading">Lazy loading</see> for more information. /// </remarks> /// <typeparam name="TRelated">The type of the navigation property.</typeparam> /// <param name="loader">The loader instance, which may be <see langword="null" />.</param> /// <param name="entity">The entity on which the navigation property is located.</param> /// <param name="navigationField">A reference to the backing field for the navigation.</param> /// <param name="navigationName">The navigation property name.</param> /// <returns> /// The loaded navigation property value, or the navigation property value unchanged if the loader is <see langword="null" />. /// </returns> public static TRelated?Load <TRelated>( this ILazyLoader?loader, object entity, ref TRelated?navigationField, [CallerMemberName] string navigationName = "") where TRelated : class { loader?.Load(entity, navigationName); return(navigationField); }
/// <summary> /// Loads a navigation property if it has not already been loaded. /// </summary> /// <typeparam name="TRelated"> The type of the navigation property. </typeparam> /// <param name="loader">The loader instance, which may be <see langword="null" />.</param> /// <param name="entity"> The entity on which the navigation property is located. </param> /// <param name="navigationField"> A reference to the backing field for the navigation. </param> /// <param name="navigationName"> The navigation property name. </param> /// <returns> /// The loaded navigation property value, or the navigation property value unchanged if the loader is <see langword="null" />. /// </returns> public static TRelated Load <TRelated>( [CanBeNull] this ILazyLoader loader, [NotNull] object entity, [CanBeNull] ref TRelated navigationField, // ReSharper disable once AssignNullToNotNullAttribute [NotNull][CallerMemberName] string navigationName = null) where TRelated : class { // ReSharper disable once AssignNullToNotNullAttribute loader?.Load(entity, navigationName); return(navigationField); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void Intercept(IInvocation invocation) { var methodName = invocation.Method.Name; if (methodName.StartsWith("get_", StringComparison.Ordinal)) { var navigationName = methodName.Substring(4); var navigation = _entityType.FindNavigation(navigationName); if (navigation != null) { _loader.Load(invocation.Proxy, navigationName); } } invocation.Proceed(); }
public void Load(object entity, [CallerMemberName] string navigationName = null) { if (ContextIsDisposed) { return; } var originalChangeTrackingState = AutoDetectChangesEnabled; try { AutoDetectChangesEnabled = false; _efCoreLazyLoader.Load(entity, navigationName); } finally { if (originalChangeTrackingState) { AutoDetectChangesEnabled = true; } } }
public async Task <TValue> Request() { if (_cached) { return(_cachedValue); } await _thisLock.WaitAsync() .ConfigureAwait(false); try { if (_cached) { return(_cachedValue); } // need to access the db await _databaseLock.WaitAsync() .ConfigureAwait(false); try { _cachedValue = _lazyLoader.Load(); _cached = true; return(_cachedValue); } finally { _databaseLock.Release(); } } finally { _thisLock.Release(); } }
/// <inheritdoc /> public TPost Load() { var loaded = _pre.Load(); return(_transformer.TransformPre(loaded)); }