1)
QueryComplete = Query.EQ(_id, "2012_11_10"); DayData myData = db.GetCollection<DayData>("DayDataCollection").FindOne(query);
2)
QueryComplete = Query.EQ(_id, "2012_11_10"); UpdateBuilder update = Update.Inc("HR1.Count", 1); db.GetCollection<DayData>("DayDataCollection").Update(query, update, SafeMode.True)
;
3) In your case, you simply extract an instance of DayData and then summarize all the necessary values โโexplicitly:
QueryComplete = Query.EQ(_id, "2012_11_10"); DayData myData = db.GetCollection<DayData>("DayDataCollection").FindOne(query);
But it is not elegant. If you want an elegant solution, you need to convert your fields to an array, for example:
DayData { HR: [{ Count: 1, Data: "Hour 1 data" }, { }, ... ] }
and work like an array. Let me know if it is possible to convert it to an array.
4) In your case, again, there is no elegant solution. What you can do is simply go through your fields and create an array:
int[] Counts = new int[24]; Counts[0] = myData.HR1.Count; ...
Or you can create an enumerator directly in the class, but I think this is overkill in your case.
source share