Ah, of course! Thank you. On Mon, Aug 23, 2010 at 2:16 PM, Markus Zywitza <[email protected]> wrote: > session.Load<Project>(projectId) creates a proxy that loads the instance > only when you access any field other then the id. > > You can assign this object to set the reference without loading the object > from the DB. > > -Markus > > 2010/8/23 Mark Wilkins <[email protected]> >> >> 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. >> > > -- > 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. >
-- 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.
