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

            CollectionEntry <TEntity, TProperty> collection = _dbContext.Entry(entity).Collection(childs);

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

                CollectionEntry <TDto, TProperty> collection = _dbContext.Entry(dto).Collection(childs);

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