NHibernate - mapping two collections of the same type to database -



NHibernate - mapping two collections of the same type to database -

nhibernate mapping question. have entity called user , entity called menu. user contains 2 collections of menus.

public class user { public list<menu> history {get; set;} public list<menu> favourites {get; set;} } public class menu { public string name {get; set;} ... }

is there anyway could, without creating new entity, generate 2 relationship tables user , menu (userhistory , userfavourites probably...), each contains mapping userids menuids? can done mappings only(fluentnhibernate mapping if possible)? or there improve way trying here?

thank you.

i'd utilize

public class usermap : classmap<user> { references(m => m.history).column("historyid"); references(m => m.favourites).column("favouritesid"); }

in users

and sub class menu userhistory , userfavourites.

public class menumap : classmap<menu> { public parentmap() { id(x => x.id); map(x => x.name); discriminatesubclassesoncolumn("type"); } } public class childmap : subclassmap<child> { public childmap() { map(x => x.anotherproperty); } }

nhibernate fluent-nhibernate nhibernate-mapping fluent-nhibernate-mapping

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -