简体   繁体   中英

MongoDB and C#, how to compare by day of week

In C# I have to get all documents, that have a date property that falls on a specific day of week (Monday for example).

How can I do that? I tried simply comparing the DayOfWeek property like this:

Builders<TEntity>.Filter.Where(x=>x.Start.DayOfWeek == weekday);

But I get an error:

Convert({document}{Start}.DayOfWeek) is not supported.

"weekday" is a DayOfWeek, "DayOfWeek.Monday" for example.

You can use MongoDB Driver Linq3. You can reference this link: https://www.mongodb.com/community/forums/t/how-to-filter-by-day-of-week/148776

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM