Пример #1
0
        private async Task <bool> CheckIfExistTable <T>() where T : new()
        {
            var connection = _sqliteWrapper.OpenDatabase();

            try
            {
                var result = await connection.Table <T>().CountAsync();

                return(result.Equals(0));
            }
            catch (Exception e)
            {
                Logs.Logs.Error($"Error get count table {typeof(T).Name}: {e.Message}");
                return(false);
            }
        }
Пример #2
0
        public async Task <T> GetOneObjectById <T>(int id) where T : new()
        {
            var connection = _sqliteWrapper.OpenDatabase();
            var result     = await connection.FindAsync <T>(id);

            if (result == null)
            {
                throw new SqliteServiceException(TableSql.Select, typeof(T).Name, $"Not found id = {id}");
            }

            return(result);
        }