Hello all
I am playing with 3.2 mapping by code convention
I have
public class MyEntity : Entity
{
..................
public virtual IEnumerable<string> LinesBag { get; set; }
}
And next mapping:
m_mapper.BeforeMapBag += (insp, prop, map) =>
{
var tn = String.Concat(prop.GetContainerEntity(insp).Name, "_",
prop.ToColumnName()).ToUpperInvariant();
map.Table(tn);
map.Key(km =>
{
km.Column(cm =>
{
var cn = String.Concat(prop.GetContainerEntity(insp).Name,
"_ID").ToUpperInvariant();
cm.Name(cn);
cm.Index(String.Concat("IFK_", cn));
});
km.ForeignKey(String.Concat("FK_", tn, "_2_",
prop.GetContainerEntity(insp).Name.ToUpperInvariant()));
}
);
};
m_mapper.Class<MyEntity>(map =>
{
//....................
map.Bag(x => x.LinesBag,
colmap => { },
xmap =>
{
xmap.Element(em =>
{
em.Column("Element");
});
}
);
});
As result NHibernate generate next script
create table MYENTITY_LINESBAG (MYENTITY_ID UNIQUEIDENTIFIER not null,
Element NVARCHAR(255) null)
create index IFK_MYENTITY_ID on MYENTITY_LINES (MYENTITY_ID)
alter table MYENTITY_LINESBAG add constraint FK_MYENTITY_LINESBAG_2_MYENTITY
foreign key (MYENTITY_ID) references MYENTITY
The questions:
1) Can i define column "Element" (It's name size and so on) not in explicit
mapping but in convention rules BeforeMapBag and so on?
2) Can i define somehow covering index for this case
create index IFK_MYENTITY_ID on MYENTITY_LINES (MYENTITY_ID, Element)
?
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/a2B-d6KDE8oJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.