Because if I remove the property(and ofcouce the belongsto relation) I get an error ..
System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'BlogId'.... And as fare as I Know about databases and Nhibernate, I need the blogId as my foreignkey. I dont see how nhibernate else would know how to make the relation between Blog and Post if i remove BlogId from Post. :/ On Jan 12, 11:34 am, "Markus Zywitza" <[email protected]> wrote: > Then why do have the BlogId property in there? Simply discard it. > > -Markus > > 2009/1/12 Mark Jensen <[email protected]>: > > > > > haven't tested it yet, but is it really required to make it > > bidirectional for this to work ? > > > because I only need it to go one way :/ > > > On Jan 10, 2:41 pm, "Markus Zywitza" <[email protected]> wrote: > >> > public class Post : BaseEntity<Post> > >> > { > >> > [Property("BlogId", NotNull = true)] > >> > public Guid BlogId > >> > { > >> > get { return blogId; } > >> > set { blogId = value; } > >> > } > > >> [BelongsTo("BlogId")] > >> public Blog Blog {get; set;} > > >> > } > >> >> > anyway...it is not the ID on Post that is the problem.. it is the > >> >> > BlogID on Post that is empty after I persist Blog with Blog.Save(). > > >> Of course, it is changed in the DB but not in the object. Call > >> post.Refresh() to reload it. If you implement it as I have written > >> above, you could also set Blog on the post instance instead. > > >> public void AddPost(Post post) > >> { > >> posts.Add(post); > >> post.Blog=this; > >> } > > >> -Markus --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" 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/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
