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].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.