I have a table in my database looking roughly like this:
create table Foo (
Id int identity not null,
Name varchar(100) not null,
GroupName varchar(100) not null,
constraint PK_Foo primary key (Id)
)
Now I want to map this table into two entity classes like this:
class Foo {
public virtual in Id { get; private set; }
public virtual string Name { get; set; }
public virtual Group Group { get; set; }
}
class FooGroup {
public virtual string Name { get; set; }
public virtual ISet<Foo> Foos { get; private set; }
}
Is this possible with NHibernate? I have tried to search the net and NH docs, but I really don't know what to look for - ideas for search queries would be appreciated.
Maybe I can make a mapping for FooGroup
that uses a custom HQL/SQL query to select the distinct group names, and another custom query to select the appropriate set of contained items?