Created
September 26, 2012 19:43
-
-
Save g0t4/3790130 to your computer and use it in GitHub Desktop.
Mapping a collection of Components in FluentNhibernate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Approved | |
{ | |
public virtual Guid Id { get; set; } | |
public virtual IEnumerable<Entry> Entries { get; set; } | |
} | |
public class Entry | |
{ | |
public virtual Guid Id { get; set; } | |
public virtual Guid Description { get; set; } | |
} | |
// Mapping, Table specifies the table name to use, Component specifies the columns to map of the component, KeyColumn specifies the foreign key in the table to link back to the parent Approved item, it's also possible to re-use an existing component map instead of manually mapping each time | |
HasMany(a => a.Entries) | |
.Table("ApprovedEntries") | |
.KeyColumn("ApprovedId") | |
.Component(c => | |
{ | |
c.Map(e => e.Id); | |
c.Map(e => e.Description); | |
}) | |
.Cascade | |
.AllDeleteOrphan() | |
.Not.LazyLoad() | |
.BatchSize(1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment