views:

78

answers:

0

I've recently started using NHibernate and have very little experience. I have table Projects which can't be changed since it's a part of older system. I need to add ProjectGroup table represeting group of project, so that one project is assigned to only one particular group and group can have many projects assigned to it. I wonder if there is a way to map this relationship so it would look like this in code:

public class Project {
    public virtual int Id {get;set}
    public virtual string Name {get;set;}
    public virtual ProjectGroup Group {get;set;}
}

public class ProjectGroup {
    public virtual int Id {get;set;}
    public virtual string Name {get;set;}
    public virtual int Ordering {get;set;}
    public virtual IList<Project> Projects {get;set;}
}

and if it's not possible what would be the proper way to do this?