Take the community feedback survey now.
                AI OnAI Off
            
        Take the community feedback survey now.
 
                        private readonly IContentTypeRepository _contentTypeRepository;
        private readonly IContentModelUsage _contentUsageLoader;
        private IEnumerable<ContentUsage> GetBlockReferencesByType<T>() where T : BlockData
        {
            var contentType = _contentTypeRepository.Load<T>();
            var usages = _contentUsageLoader.ListContentOfContentType(contentType).ToList();
            return usages;
        }
Beware the performance implications as this isn't a common use case for run-time it doesn't come with built-in performance optimization.
This is basically a function for editors, so yes, it's not performance optimized (would be quite difficult as well). So make sure you don't use this on an end-user faced feature.
Oh I wanna find a block is used how many times, not how many instances are there a Block Type has.
But I found the solution for my question.
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>(); var timesIsUsed = contentRepository.GetReferencesToContent(block.ContentLink, false);
Thanks for your answer :D
 
    
    
    
Hi,
As the subject of this topic, I need to check a block is used or never used, and how many times that a block is used on the site.
Has anyone the solution for my issue?
Thanks very much, :D