As reported in the comment, the problem is to apply an only date filter on an Unix timestamp containg time information, too.Since .Net MongoDb driver is unable to convert dates to string applying provided format, we can try to apply the opposite approach I used in the previous example to both the start of the current day and the start of next day, converting the == condition to a new condition based on < and >=:var now = DateTime.UtcNow;var currentDate = now.Date;var tomorrow = currentDate.AddDays(1);var left = currentDate.ToUnixTimeSeconds();var right = tomorrow.ToUnixTimeSeconds();var results = await Settings.DataBase.GetCollection<Video>("Videos") .Find(x => x.ViewsToday != null && x.ViewsToday.Date >= left && x.ViewsToday.Date < right) .ToListAsync(); 这篇关于MongoDB查找|例外-不支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-21 17:32