Reputation: 63
After searching around the web I found a mapping that gets most of the job done:
In my class I have:
public virtual IDictionary<int, string> _properties { get; set; }
And in the mapping:
HasMany(x => x._properties)
.AsMap<string>(index => index.Column("PropertyID").Type<int>(),
element => element.Column("Value").Type<string>())
.KeyColumn("ID")
.ForeignKeyConstraintName("FK_DeftoProperties")
.Table("Definition_Property")
.Not.LazyLoad()
.Access.Property()
.Cascade.All();
Which results in this table definition:
create table Definition_Property (
ID UNIQUEIDENTIFIER not null,
Value NVARCHAR(255) null,
PropertyID INT not null,
primary key (ID, PropertyID)
)
However I need the "Value" to be longer that 255 and changing the mapping to:
element => element.Column("Value").Type<string>().Length(500)
doesn't have any affect on the table generation.
If I map it using an hbm file:
I get the table I expected.
Any ideas on how to set the length fluently?
Upvotes: 1
Views: 1205