public QueryAccessor() { var link = typeof(TableKey).GetCustomAttribute <TableLink>(); if (link != null) { if (!SqlManager.TrySearchDatabase(link.DatabaseType, out _database)) { throw new ArgumentNullException(link.DatabaseType.Name, "Invalid Database for the QueryAccessor."); } } else { var tableName = typeof(TableKey).Name; throw new ArgumentNullException(tableName, $"No Database attached to { tableName } table."); } }
protected Table() { var link = GetType().GetCustomAttribute <TableLink>(false); if (link != null) { Identifier = link.TableName; if (link.DatabaseType != null && SqlManager.TrySearchDatabase(link.DatabaseType, out Database db)) { Database = db; } if (Database == null) { throw new ArgumentNullException($"The database isn't registered for table '{ link.TableName }'"); } } }