public class ScheduledEvent : Event
{
public DateTimeOffset StartDateTime { get; set; }
}
StartDateTime = 2013/05/27 02:09:00 00: 00 che rappresenta 2013/05/26 19:09 PSTcorrettamente utilizzando/movimentazione DateTimeOffset in MongoDB
cosa è registrato in MongoDB:
> db.ScheduledEvent.find().toArray()
[
{
"_id" : BinData(3,"ZE2p31dh00qb6kglsgHgAA=="),
"Title" : "Today 26th at 7:09pm",
"Length" : "00:00:00",
"MoreInformation" : "http://1.com",
"Speakers" : [
{
"_id" : BinData(3,"ndzESsQGukmYGmMgKK0EqQ=="),
"Name" : "Mathias Brandewinder"
}
],
"Location" : {
"_id" : BinData(3,"AAAAAAAAAAAAAAAAAAAAAA=="),
"Name" : "Somwhere "
},
"Organizers" : [
{
"_id" : BinData(3,"AAAAAAAAAAAAAAAAAAAAAA=="),
"Name" : null
}
],
"CreatedOn" : [
NumberLong("635052144104050898"),
0
],
"StartDateTime" : [
NumberLong("635052173400000000"),
0
]
}
]
Mi rendo conto che StartDateTime è memorizzato come zecche in MongoDB.
var dateMarker = DateTimeOffset.UtcNow;
var nextDay = dateMarker.AddDays(1);
Questa query non funziona:
var today = EventRepoistory.All().Where(z => z.StartDateTime >= dateMarker && z.StartDateTime < nextDay).OrderByDescending(z => z.StartDateTime).ToList();
Ho aggiunto un display query per il driver # Mongo C che mostra la seguente query:
{ "$query" : { "StartDateTime" : { "$gte" : [NumberLong("635052168609734070"), 0], "$lt" : [NumberLong("635053032609734070"), 0] } }, "$orderby" : { "StartDateTime" : -1 } }
Limite inferiore = 6.350.521 68609734070
Server = 6350521 7340000 0000
Limite superiore = 6350530 32609734070
Domanda: Perché l'interrogazione MongoDB non tornare nulla?
db.ScheduledEvent.find ({ "$ query": { "StartDateTime": { "$ gte": [NumberLong ("635.052.168.609,73407 milione"), 0], "$ lt": [NumberLong (" 635.053.032.609,73407 milione"), 0]}}, "$ orderby": { "StartDateTime": -1}})
Ricercato:
MongoDB and DateTimeOffset type ma cuciture che fornitore di LINQ sta facendo quello che si suppone?
provato:
db.ScheduledEvent.find({ "StartDateTime" : { "$gte" : [NumberLong("1"), 0] } } )
produce alcun risultato.
Ciao, sei mai arrivato in fondo a questo? Ho lo stesso problema ... – soupy1976
Ho sospeso il mio progetto dopo questa scoperta. Non sono ancora tornato. –