public async Task <DbSpace> CreateAsync(DbSpace space)
        {
            EntityEntry <DbSpace> result = dbContext.Spaces.Add(space);
            await dbContext.SaveChangesAsync();

            return(result.Entity);
        }
        private async Task LoadNestedSpaces(DbSpace parent)
        {
            if (parent == null)
            {
                return;
            }

            var result = Parallel.ForEach(
                parent.Spaces,
                async(space) =>
            {
                await dbContext.Entry(space).Collection(s => s.Spaces).LoadAsync();
                await dbContext.Entry(space).Reference(s => s.MapFile).LoadAsync();
                await dbContext.Entry(space).Reference(s => s.SpaceType).LoadAsync();
                await LoadNestedSpaces(space);
            });
        }
 public async Task DeleteAsync(DbSpace space)
 {
     dbContext.Spaces.Remove(space);
     await dbContext.SaveChangesAsync();
 }