This may be a very *basic* question, but I'm beginning to learn, and
am looking to do things the right way.

I have a User entity that has a default Project...

public class User {
        public int UserId {get; protected set; }
        public string Name {get; set; }
        public Project DefaultProject {get; set; }
}

The underlying table, User, has the following attributes:
UserId int not null
, Name varchar(100) not null
, DefaultProjectId int not null

If I want to persist a new User, I need to have a Project instance.
But, perhaps I don't want to load a project from the database, just to
create a new user. I already know the ProjectId, so I was thinking
of...

User user = new User();
user.Name = "test";
user.DefaultProject = new Project(projectId); // a constructor that
sets the project id
// save

Is this common? Or is there a better way in NHibernate?

Mark

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to