NHibernate foreign key set -


i have a:

class garage {     int garageid;     iset<car> cars } 

should cars class have garageid 1 of properties, in:

class car {    int carid;    int garageid;    string name; } 

that how appears in database, wondering if classes on many side supposed have foreign key property or if orm adds in when performing sql (assuming can specify in mappings file).

in short: no. (and yes orm take care of fk based on mapping files)

the "car" table have garageid in should not add car class.

you can have bi-directional relationship (although opinions vary on whether these idea).

a bi-directional relationship make car class this:

public class car {      public virtual int id {get; set;}      public virtual garage garage {get; set;}  //you can traverse garage      public virtual string name {get; set;} } 

if me post fluent/xml maps let me know.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -