Since NH cannot know in advance from which table the items come, it has to
load them from all the tables. The best approach would be having a
collection of intermediate objects that have a single Any reference.

-Markus

2009/9/11 JakeS <[email protected]>

>
> I have a system where categories can be assigned to multiple objects
> (such as a Calendar Event or an Action Item) within the system.  Each
> of those objects shares an Interface -- ICategoryItem.  Then in the
> category I have mapped it like this:
>
> private IList<ICategoryItem> _items;
> [HasManyToAny(typeof(ICategoryItem), "CategoryID", "CategoryItems",
> typeof(int),
>    "TypeOfItem", "Item_ID", MetaType = typeof(string), Lazy = true)]
> [Any.MetaValue("ACTIONITEM", typeof(ActionItem))]
> [Any.MetaValue("DISCUSSION", typeof(Discussion))]
> [Any.MetaValue("EVENT", typeof(CalendarEvent))]
> [Any.MetaValue("LIBRARYOBJECT", typeof(LibraryObject))]
> [Any.MetaValue("WHITEBOARD", typeof(WhiteBoard))]
> public IList<ICategoryItem> Items
> {
>    get
>    {
>        if (_items == null) { _items = new List<ICategoryItem>(); }
>        return _items;
>    }
>    set
>    {
>        _items = value;
>    }
> }
>
> This works pretty well, but every time the category.Items is accessed
> it fires off a LOT of queries--
> Select ... FROM CategoryItems
> Select ... From Discussion
> Select ... From Discussion
> Select ... From Discussion
> and so on.
>
> Can anyone offer any advice on improving this?  Is there a simple
> solution, or should I just break this relationship alltogether and
> have the items be a list of basic object information, then use that to
> find the real object later if needed?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to