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 SetUp() { this.mapping = new KeyPropertyMapping(); this.part = new KeyPropertyPart(mapping); }