Hi,I have a list of ContentArea items on a particular block.The structure of the block is as follows:Contact Block
This main Contact block is added on a page.The approx. contact items in a single contact block is around 900+.I need to get the contact items on my UI but before I get it,I need to include some filters to it so that the final content area items are based on the filter & not all of the 900+ items.
I have added the below query which works fine but the problem here is, it gets all the Contact Items first & then apply filters which is why it takes a lot of time more like in minutes.
var contactItems = currentBlock.ContactItemContentArea.FilteredItems
.Select(contentItem => _contentRepository.Get<ContactItemBlock>(contentItem.ContentLink))
.Where(item => item.Area == "Management" && item.Department == "Finance" && item.Location == "US");
Is there a more efficient way to filter these contentarea items ?
If you're using Search & Navigation you could instead just query using Search<ContactItemBlock> blocks that have a) are matching in the ContentLinks from the FilteredItems and b) by your 3 Area types. This will return them via the search service instead of loading them via the database so should be a lot faster. Then it's up to you if you can just use the data loaded directly from S&N or reload them via the IContentLoader
Having 900+ blocks on a single page is a lot.
Have you considered changing the architecture and storing contacts in a custom database table(s), for example?
Another option would be to use pages instead of blocks.
You can group them by Location, Department, and Area instead of having 900+ pages under the same node.
If Search is not an option, you might consider using Content Output and/or object caching.
Hope this helps!