I would like in the GetAll function to already bring the list of posts in order according to the list of IDs passed by the 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);
}
The system uses 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();
}
I have tried the following unsuccessful code:
var query = from i in ids
join o in collection..AsQueryable()
on i equals o.Id
select o;