Gostaria de na função GetAll já trouxesse a lista de posts em ordem de acordo com a lista de IDs passados pelo parâmetro module.Higlights
List<Post> posts = new List<Post>();
var posts = PostService.GetAll(module.Highlights).ToList();
var postsAux = posts;
posts.Clear();
foreach (var item in module.Highlights){
var post = postAux.FirstOrDefault(p => p.Id == item);
if(post != null)
posts.Add(post);
}
O sistema utiliza o IMongoCollection:
public IEnumerable<Post> GetAll<Post>(IEnumerable<string> ids)
{
if (ids == null)
return new List<Post>();
var collection = Db.GetCollection<Post>(typeof(Post).Name);
var filter = Builders<Post>.Filter.In("Id", ids);
return collection.Find(filter).ToList();
}
Já tentei o seguinte código sem êxito:
var query = from i in ids
join o in collection..AsQueryable()
on i equals o.Id
select o;