Skip to content

Instantly share code, notes, and snippets.

@NickBranstein
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save NickBranstein/c3071fb8c008a666a13a to your computer and use it in GitHub Desktop.

Select an option

Save NickBranstein/c3071fb8c008a666a13a to your computer and use it in GitHub Desktop.
Inverse Bag
public class Student
{
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
public virtual IEnumerable<Classroom> Classrooms { get; set; }
public virtual Teacher Teacher { get; set; }
}
public class Teacher
{
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
public virtual IEnumerable<Student> Students { get; set; }
}
public class TeacherMap : ClassMapping<Teacher>
{
public TeacherMap()
{
Bag(x => x.Students, m =>
{
m.Lazy(CollectionLazy.Lazy);
m.Inverse(true);
m.Key(km => km.Column(typeof(Teacher).Name));
}, map => map.OneToMany(a => a.Class(typeof(Student))));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment