System.InvalidOperationException: 'Parse({document}{processeddate}) is not supported.'
The exception was thrown on the line following.
result = trackCollection.Aggregate()
.Match(x => DateTime.Parse(x.ProcessedDate) > DateTime.Now.AddMinutes(-3))
.ToList();
public class Track
{
[BsonElement("processeddate")]
public string ProcessedDate { get; set; }
...
}
processeddate
is a string in MongoDB collection.
How to compare string and date time in Match
expression using EFCore MongoDB driver?
Although it works I don't prefer this way due to performance issues:
result = trackCollection.Aggregate()
.ToList()
.Where(x => DateTime.Parse(x.ProcessedDate) > DateTime.Now.AddMinutes(-3))
.ToList();