public IndexSortAndFilterTest() { _tempFile = new TempFile(); _database = new LiteDatabaseAsync(_tempFile.Filename); _collection = _database.GetCollection <Item>("items"); var task1 = _collection.UpsertAsync(new Item() { Id = "C", Value = "Value 1" }); var task2 = _collection.UpsertAsync(new Item() { Id = "A", Value = "Value 2" }); var task3 = _collection.UpsertAsync(new Item() { Id = "B", Value = "Value 1" }); Task.WaitAll(task1, task2, task3); var task4 = _collection.EnsureIndexAsync("idx_value", x => x.Value); task4.Wait(); }
public async Task <List <T> > GetAllRecordsAsync <T>(LiteCollectionAsync <T> collection) { List <T> recordsList = await collection.Query().ToListAsync(); logger.Info("Retrieved {0} objects from database", recordsList.Count); return(recordsList); }
public Person_Tests() { this.local = DataGen.Person().ToArray(); _db = new LiteDatabaseAsync(":memory:"); _collection = _db.GetCollection <Person>("person"); var task = _collection.InsertAsync(this.local); task.Wait(); }
public async Task InsertRecordsAsync <T>(List <T> recordsList, LiteCollectionAsync <T> collection) { bool insertSuccessful = true; foreach (var item in recordsList) { if (!(await collection.UpsertAsync(item))) { insertSuccessful = false; } } if (insertSuccessful) { logger.Info("Records were inserted successfully"); } else { logger.Info("An error occurred while inserting records"); } }
public async Task DeleteAllRecordsAsync <T>(LiteCollectionAsync <T> collection) { int noOfDeletedEntries = await collection.DeleteAllAsync(); logger.Info("Cache was purged. {0} entries deleted", noOfDeletedEntries); }