tag:blogger.com,1999:blog-6038034264692630628.post3474789058462548021..comments2023-04-11T14:28:06.126+02:00Comments on NOtherDev: Mapping-by-Code - OneToMany and other collection-based relation typesAdam Barhttp://www.blogger.com/profile/16605796098913600806noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-6038034264692630628.post-19095208768627749972015-06-16T23:08:58.484+02:002015-06-16T23:08:58.484+02:00The fourth paragraph starts with these lines: &quo...The fourth paragraph starts with these lines: "In mapping-by-code, the relation type is defined in the third parameter of Set/Bag mapping. It is optional, with default one-to-many."<br /><br />Maybe it's changed since the article was written, but I found that I could not leave out the "r => r.OneToMany()" relation specifier for a Set() call, or things would not work. Just a warning to future readers.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6038034264692630628.post-52807025097507527192013-02-16T11:54:42.024+01:002013-02-16T11:54:42.024+01:00But what code? :)But what code? :)Adam Barhttps://www.blogger.com/profile/16605796098913600806noreply@blogger.comtag:blogger.com,1999:blog-6038034264692630628.post-61778323176617719772013-02-15T22:31:10.535+01:002013-02-15T22:31:10.535+01:00Would it be possible for you to post your code, pl...Would it be possible for you to post your code, please?<br /><br />Thank you.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6038034264692630628.post-57104833806204923872012-10-12T08:54:18.246+02:002012-10-12T08:54:18.246+02:00I haven't tried, but it should. Try with x =&g...I haven't tried, but it should. Try with x => x.ManyToMany(r => r.Columns(...))Adam Barhttps://www.blogger.com/profile/16605796098913600806noreply@blogger.comtag:blogger.com,1999:blog-6038034264692630628.post-51224260727587339972012-10-12T02:29:21.266+02:002012-10-12T02:29:21.266+02:00Aaah you are right. Off the top you head, do you k...Aaah you are right. Off the top you head, do you know if a Many to Many relationship with composite keys is currently being supported? I might have to drop mapping-by-code if this doesn't work! Anonymoushttps://www.blogger.com/profile/01390415633022423304noreply@blogger.comtag:blogger.com,1999:blog-6038034264692630628.post-12697996569364368402012-10-11T19:58:47.553+02:002012-10-11T19:58:47.553+02:00Well, that's extremely exotic case, I wouldn&#...Well, that's extremely exotic case, I wouldn't be surprised if it is not supported. Anyway, this is not one-to-many for sure, try with <a href="http://notherdev.blogspot.com/2012/01/mapping-by-code-onetoone.html" rel="nofollow">one-to-one</a>.Adam Barhttps://www.blogger.com/profile/16605796098913600806noreply@blogger.comtag:blogger.com,1999:blog-6038034264692630628.post-70218371228584411142012-10-11T13:56:22.946+02:002012-10-11T13:56:22.946+02:00Great summary, but there is still so many question...Great summary, but there is still so many questions for a beginners (like me!)<br /><br />How do I map a one to many relationship where the parent table's primary key (which is a composite key, and a component) is the foreign key (and primary key) in the child table?!?<br /><br />Is it possible?<br /><br />http://stackoverflow.com/questions/12836288/nhibernate-3-3-mapping-one-to-many-relationship-with-composite-foreign-keysAnonymoushttps://www.blogger.com/profile/01390415633022423304noreply@blogger.comtag:blogger.com,1999:blog-6038034264692630628.post-28545034310082138532012-01-26T23:34:48.726+01:002012-01-26T23:34:48.726+01:00Thanks for the advice Adam... mapping by code seem...Thanks for the advice Adam... mapping by code seems to be the sensible option going forward. I just need to convince my team its the best option.<br /><br />Keep the posts coming! :)Chrishttps://www.blogger.com/profile/06817275296074067231noreply@blogger.comtag:blogger.com,1999:blog-6038034264692630628.post-12597964804409072092012-01-26T09:10:51.448+01:002012-01-26T09:10:51.448+01:00Thanks!
A month ago I would still recommend FNH a...Thanks!<br /><br />A month ago I would still recommend FNH as it looked more mature and there are a lot of examples, but now, after spending quite a lot of time with mapping-by-code, I find it quite powerful. Big advantage is that it is more efficient (no XML serialization) and more coupled to NHibernate itself - no additional dependency. And the lack of examples hopefully is fixed a bit by my series. I'll go with mapping-by-code now.Adam Barhttps://www.blogger.com/profile/16605796098913600806noreply@blogger.comtag:blogger.com,1999:blog-6038034264692630628.post-11998773386949902852012-01-25T23:47:04.236+01:002012-01-25T23:47:04.236+01:00Great posts... Really hard to find any info on map...Great posts... Really hard to find any info on mapping by code.<br /><br />I've been trying to choose FHN or mapping by code for my next project and find both seem equal in the pros and cons... Being a total noob to nh would u recommend one over the other?Chrishttps://www.blogger.com/profile/06817275296074067231noreply@blogger.com