Ah... I have forgot something... If you use <bag> the collection is no retrieved by adding an element... but you know bag != set
2010/1/13 Fabio Maulo <[email protected]> > and a roundtrip with a select and an INSERT without a Commit of the UoW is > smarter than a roundtrip with a select ? > how much smart is that select ? > what will happen with the second Add ? (with the current behaviour you will > have *zero* roundtrip and no insert until UoW commit) > > As I said in another occasion smarter or not is a subjective opinion, what > is important is that NH is giving you the ability to define what is smarter > for you; in this case with, at least, two ways : > 1) IUserCollectionType > 2) ICollectionTypeFactory > > If your intention is propose a possible improvement you can use our > issues-tracker and/or our development-list. > > 2010/1/13 Jørn Schou-Rode <[email protected]> > >> Say, I have a Newsletter class with this property: >> >> ICollection<string> Subscribers { get; private set; } >> >> Mapped like this: >> >> <set name="Subscribers" table="Subscriber" lazy="extra"> >> <key column="NewsletterID" /> >> <element column="EmailAddress" /> >> </set> >> >> The lazy=extra setting improves scalability in scenarios such as: >> >> - selecting the count of subscribers for a newsletter >> - checking if a specific email address is subscribed >> >> I would expect adding an extra subscriber to a newsletter would be >> "cheap" as well. This code: >> >> newsletter42.Subscribers.Add("[email protected]") >> >> should translate to something like this SQL: >> >> if not exists ( select 1 from Subscriber where NewsletterID = 42 and >> EmailAddress = '[email protected]' ) >> insert into Subscriber ( NewsletterID, EmailAddress ) values ( 42, >> '[email protected]' ) >> >> but it does not. Instead it causes the application to select all >> subscribers for the newsletter, and then inserting new subscriber >> after doing the duplicate check in-memory. >> >> Why is that? As NH seems to be built by people way smarter than me, I >> expect there is a very good reason why it behaves the way it does. >> >> Thanks in advance. >> >> -- >> 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]<nhusers%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/nhusers?hl=en. >> >> >> >> > > > -- > Fabio Maulo > > -- Fabio Maulo--
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.
