public void WhenKeyPropertyMappingContainsLengthAndCustomColumnLengthAttributeIsRenderedIntoColumnElement() { var keyPropertyMapping = new KeyPropertyMapping(); keyPropertyMapping.Set(propertyMapping => propertyMapping.Length, Layer.Defaults, 2); keyPropertyMapping.AddColumn(new ColumnMapping()); writer.VerifyXml(keyPropertyMapping).DoesntHaveAttribute("length").Element("column").HasAttribute("length", "2"); }
KeyPropertyPart Map(Member member, string columnName) { var type = member.PropertyType; if (type.IsEnum) { type = typeof(GenericEnumMapper <>).MakeGenericType(type); } var property = new KeyPropertyMapping { Name = member.Name, Type = new TypeReference(type), ContainingEntityType = typeof(T) }; if (!string.IsNullOrEmpty(columnName)) { property.AddColumn(new ColumnMapping { Name = columnName }); } mapping.AddProperty(property); return(new KeyPropertyPart(property)); }
public KeyPropertyPart ColumnName(string columnName) { mapping.AddColumn(new ColumnMapping { Name = columnName }); return(this); }
protected virtual CompositeIdentityPart <T> KeyProperty(Member property, string columnName, Action <KeyPropertyPart> customMapping) { var key = new KeyPropertyMapping { Name = property.Name, Type = new TypeReference(property.PropertyType), ContainingEntityType = typeof(T) }; if (customMapping != null) { var part = new KeyPropertyPart(key); customMapping(part); } if (!string.IsNullOrEmpty(columnName)) { key.AddColumn(new ColumnMapping { Name = columnName }); } keyProperties.Add(key); return(this); }
protected virtual CompositeIdentityPart <T> KeyProperty(Member member, string columnName, Action <KeyPropertyPart> customMapping) { var type = member.PropertyType; if (type.IsEnum) { type = typeof(GenericEnumMapper <>).MakeGenericType(type); } var key = new KeyPropertyMapping { ContainingEntityType = typeof(T) }; key.Set(x => x.Name, Layer.Defaults, member.Name); key.Set(x => x.Type, Layer.Defaults, new TypeReference(type)); if (customMapping != null) { var part = new KeyPropertyPart(key); customMapping(part); } if (!string.IsNullOrEmpty(columnName)) { var columnMapping = new ColumnMapping(); columnMapping.Set(x => x.Name, Layer.Defaults, columnName); key.AddColumn(columnMapping); } keys.Add(key); return(this); }
public void ShouldWriteColumns() { var mapping = new KeyPropertyMapping(); mapping.AddColumn(new ColumnMapping()); writer.VerifyXml(mapping) .Element("column").Exists(); }
public KeyPropertyPart ColumnName(string columnName) { var column = new ColumnMapping(); column.Set(x => x.Name, Layer.UserSupplied, columnName); mapping.AddColumn(column); return(this); }
public void ColumnsCollectionHasSameCountAsMapping() { mapping.AddColumn(new ColumnMapping()); inspector.Columns.Count().ShouldEqual(1); }
private static KeyPropertyMapping GetKeyPropertyMapping(Type entityType, string name, Type type) { var keyPropertyMapping = new KeyPropertyMapping {ContainingEntityType = entityType}; keyPropertyMapping.Set(x => x.Name, Layer.Defaults, name); keyPropertyMapping.Set(x => x.Type, Layer.Defaults, new TypeReference(type)); var columnMapping = new ColumnMapping(); columnMapping.Set(x => x.Name, Layer.Defaults, name); keyPropertyMapping.AddColumn(columnMapping); return keyPropertyMapping; }