I'm trying to performing OrderBy
decimal property on Mongo DB collection using C# mongo driver. Since the decimal is storing has string, I am not able to achieve this. How can I perform the OrderBy on decimal property?
//In the model
public decimal PayAmount { get; set; }
//While creating a query
var predicate = PredicateBuilder.New<Documents.Job>();
predicate = predicate.And(x => x.Status == jobStatus);
var jobdata = context.Jobs.AsQueryable().Where(predicate);
var query = from a in jobdata select new { //selects Field here };
query = query.OrderByDescending(x => x.PayAmount); // this does not sort and PayAmount is decimal type
var jobs = await query.ToListAsync();