private void MinMaxCommon(UltraLiteCollection <DateTimeTest> coll) { var searchdatetime = new DateTime(2018, 02, 22, 0, 0, 10); var min = coll.Min("Date").AsDateTime; var max = coll.Max("Date").AsDateTime; var smaller = coll.FindOne(Query.LT("Date", searchdatetime)); var greater = coll.FindOne(Query.GT("Date", searchdatetime)); var all = coll.FindAll().ToList(); var linqmin = all.Min(x => x.Date); var linqmax = all.Max(x => x.Date); Assert.AreEqual(min, linqmin); Assert.AreEqual(max, linqmax); }
public LiteDBStorageItem(UltraLiteDatabase db, string key) { Key = key; _database = db; _collection = _database.GetCollection <Definition>(TableName); _filter = Query.EQ("Key", new BsonValue(key)); var doc = _collection.FindOne(_filter); if (doc == null) { _collection.Insert(new Definition { Key = key }); } else if (!string.IsNullOrWhiteSpace(doc.Json)) { data = JsonConvert.DeserializeObject <T>(doc.Json); } }