コード例 #1
0
        public void ReadAllFromList <T>() where T : new()
        {
            if (!_aweCsomeTable.Exists <T>())
            {
                return;
            }
            var spItems = _aweCsomeTable.SelectAllItems <T>();

            _log.Debug($"Replacing Data in LiteDB for {typeof(T).Name} ({spItems.Count} items)");

            DropCollection <T>(null);
            if (spItems.Count == 0)
            {
                return;
            }
            if (typeof(T).GetProperty("Id") == null)
            {
                _log.Warn($"Collection {typeof(T).Name} has no ID-Field. Cannot insert");
                return;
            }
            var targetCollection = GetCollection <T>();

            foreach (var item in spItems)
            {
                targetCollection.Insert(item);
            }
        }