private void ValidateAgainstTableMetaData(TableMetaData tableMetadata, ITypeToColumnTypeConverter converter) { if (tableMetadata == null) { throw new NoTableForDBEntityException(typeof(T), this.TableName); } var keyPropertyColumnMetaData = tableMetadata.Columns.FirstOrDefault(f => f.ColumnName == this.PrimaryKeyPropertyMapping.ColumnName); if (keyPropertyColumnMetaData == null) { throw new NoMatchingColumnForDBPropertyException(this.TableName, this.PrimaryKeyPropertyMapping.ColumnName); } foreach (var currentProperty in this.Properties) { var columnMetaData = tableMetadata.Columns.FirstOrDefault(f => f.ColumnName == currentProperty.ColumnName); if (columnMetaData == null) { throw new NoMatchingColumnForDBPropertyException(this.TableName, currentProperty.ColumnName); } if (converter.IsValidTypeForColumnType(currentProperty.Property.PropertyType, columnMetaData) == false) { throw new TypeToColumnTypeMissmatchException(typeof(T), currentProperty.Property, columnMetaData.DataType); } } this.HasBeenValidatedAgainstDatabase = true; }
public override async Task ValidateAgainstDatabase(IDatabaseSessionAsync session, ITypeToColumnTypeConverter converter) { this.ValidateAgainstTableMetaData(await session.GetTableMetaDataAsync(this.TableName), converter); }
public override void ValidateAgainstDatabase(IDatabaseSession session, ITypeToColumnTypeConverter converter) { this.ValidateAgainstTableMetaData(session.GetTableMetaData(this.TableName), converter); }
public AttributeEntityMappingProvider(ITypeToColumnTypeConverter converter) : base(converter) { }
public abstract Task ValidateAgainstDatabase(IDatabaseSessionAsync session, ITypeToColumnTypeConverter converter);
public abstract void ValidateAgainstDatabase(IDatabaseSession session, ITypeToColumnTypeConverter converter);
protected EntityMappingProvider(ITypeToColumnTypeConverter converter) { this._converter = converter; this._mappings = new Dictionary <Type, EntityMapping>(); }