public IEnumerable <IBlogPost> Create(IEnumerable <Entity> blogPostEntities) { var posts = blogPostEntities.ToArray(); var postIds = posts.Select(e => e.Id).ToArray(); var extendedDatas = _serviceContext.FetchBlogPostExtendedData(postIds, BlogCommentPolicy.Closed, _website.Id); var commentCounts = _serviceContext.FetchBlogPostCommentCounts(postIds); return(posts.Select(e => { var path = _urlProvider.GetApplicationPath(_serviceContext, e); if (path == null) { return null; } Tuple <string, string, BlogCommentPolicy, string[], IRatingInfo> extendedDataValue; var extendedData = extendedDatas.TryGetValue(e.Id, out extendedDataValue) ? extendedDataValue : new Tuple <string, string, BlogCommentPolicy, string[], IRatingInfo>(null, null, BlogCommentPolicy.Closed, new string[] {}, null); var authorReference = e.GetAttributeValue <EntityReference>("adx_authorid"); var author = authorReference != null ? new BlogAuthor(authorReference.Id, extendedData.Item1, extendedData.Item2, _archiveApplicationPathGenerator.GetAuthorPath(authorReference.Id, e.GetAttributeValue <EntityReference>("adx_blogid"))) : new NullBlogAuthor() as IBlogAuthor; int commentCountValue; var commentCount = commentCounts.TryGetValue(e.Id, out commentCountValue) ? commentCountValue : 0; return new BlogPost(e, path, author, extendedData.Item3, commentCount, GetTags(e, extendedData.Item4), extendedData.Item5); }) .Where(e => e != null) .ToArray()); }