Example #1
0
        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();
        }
Example #2
0
        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");
            }
        }