public void CheckTableScheme(TableScheme tableScheme) { Guard.NotNull(tableScheme, "tableScheme"); if (!DatabaseValidation.IsValidFileName(tableScheme.Name)) { throw new InvalidTableNameException("Table scheme has invalid name."); } if (tableScheme.Attributes.Count == 0) { throw new InvalidTableAttributesException("Table scheme has no attributes."); } HashSet <string> attributesNames = new HashSet <string>(); try { foreach (Attribute attribute in tableScheme.Attributes) { this.CheckAttribute(attribute); if (attributesNames.Contains(attribute.Name)) { throw new InvalidAttributeException($"Attribute's name \"{attribute.Name}\" is not unique."); } attributesNames.Add(attribute.Name); } } catch (InvalidAttributeException ex) { throw new InvalidTableAttributesException( "Table scheme has invalid attribute. See inner exception for details.", ex); } }
private void CheckAttribute(Attribute attribute) { Guard.NotNull(attribute, "attribute"); if (!DatabaseValidation.IsValidFileName(attribute.Name)) { throw new InvalidAttributeException($"Attribute's name \"{attribute.Name}\" is invalid."); } if (attribute.Type == null || !this._settings.DataTypes.ContainsKey(attribute.Type)) { throw new InvalidAttributeException($"Attribute's type \"{attribute.Type}\" is unknown."); } }
public bool IsValidDatabaseName(string dbName) { return(DatabaseValidation.IsValidFileName(dbName)); }