I'm trying to do sort on the basis of child element which in list of object as:
_context.Orders.AsQueryable()
.Where(predicate)
.OrderBy(x => x.Items.OrderBy( x=> x.format.format ))
.Skip(offset)
.Take(limit)
.ToList();
[BsonIgnoreExtraElements]
public class OrderDetail : Order
{
[BsonIgnoreIfNull]
public List<Item> Items { get; set; }
}
[BsonIgnoreExtraElements]
public class Item
{
public string id { get; set; }
public Format format { get; set; }
}
[BsonIgnoreExtraElements]
public class Format
{
public string format { get; set; }
}
And getting following error:
Only fields are allowed in a $sort
Views:
1433
Total Answered:
2
Total Marked As Answer:
1
Posted On:
16-Dec-2021 04:11