Exemple #1
0
        public virtual async Task LoadReferenceAsync <TProperty>(TEntity entity, Expression <Func <TEntity, TProperty> > member, CancellationToken cancellationToken)
            where TProperty : class
        {
            Attach(entity);

            ReferenceEntry <TEntity, TProperty> reference = _dbContext.Entry(entity).Reference(member);

            if (reference.IsLoaded == false)
            {
                await reference.LoadAsync(cancellationToken).ConfigureAwait(false);
            }
        }
Exemple #2
0
        public virtual async Task LoadReferenceAsync <TProperty>(TDto dto, Expression <Func <TDto, TProperty> > member, CancellationToken cancellationToken)
            where TProperty : class
        {
            try
            {
                Attach(dto);

                ReferenceEntry <TDto, TProperty> reference = _dbContext.Entry(dto).Reference(member);

                if (reference.IsLoaded == false)
                {
                    await reference.LoadAsync(cancellationToken).ConfigureAwait(false);
                }
            }
            finally
            {
                Detach(dto);
            }
        }