public static async Task AddMetadataAsync(this List <Post> posts, IMetadataService metadataService) { var meta = await metadataService.GetAsync(posts.Select(s => s.Id)); posts.ForEach(p => p.PostMeta = meta.Where(w => w.PostId == p.Id).ToList()); //foreach (var post in posts) //{ // post.PostMeta = meta.Where(w => w.PostId == post.Id).ToList(); //} }
public static async Task AddMetadataAsync(this Post post, IMetadataService metadataService) => post.PostMeta = await metadataService.GetAsync(post.Id);