People who have used MONGO know that MONGO use Bson type, there are string,int,date,bool and other data types, specifically not detailed.
There is a problem when using MONGO's C # official driver to match the data types in Bson with the data types in C #.
Here are the types of data that I encounter in the actual project that need to be matched.
Id
For example, all MONGO documents have a _id, if not identified, directly in the object class to define a _id attribute, then the data read or save the error.
Therefore, the object class should be defined as follows:
[Bsonid] Public Get set; }
Datetime
Another example is to define a datetime type in the object class, save it to MONGO and then read it and find out that the date is smaller than the date deposited.
The original MONGO database will save time to UCT time, that is, GMT, 8 hours later than Beijing time.
However, if you precede the time attribute with the following label, you can resolve the issue.
[Bsondatetimeoptions (Kind = datetimekind.local)] Public Get set; }
MONGO data type conversions in "MongoDB" C #