If you decide to use the repository pattern, then you need two sets (or namespaces) of classes: Models and Repositories. The ActiveRecord mapping will be in the Models set. Repository is should not be a model of your database and it should contain methods (combination actions and events to do CRUD).
Please Google more about repository pattern to learn more. Sincerely, William Chang On Sep 11, 3:17 pm, JakeS <[email protected]> wrote: > Thank you for the advice, but I'm still unsure exactly how to proceed, > partly because if my inexperience with using the repository pattern. > How will that help me here? > > If I make a CategoryItem Repository, won't that still have make all > these database calls? Or is this just a method of caching all that > data in memory so it only has to fetch it all the first time? > > Thanks again for the help. > > On Sep 11, 11:38 am, William Chang <[email protected]> wrote: > > > > > Even though, I don't have a solution for you... > > > From looking at your code snippet, I think your implementation of > > ActiveRecord for ICategoryItem is unnatural (neither popular pattern > > of ActiveRecord or Repository). Instead of using interface directly on > > the model (an object that represent a table), it should be an > > interface on the Repository classes. > > > Sincerely, > > William Chang > > > On Sep 11, 11:43 am, JakeS <[email protected]> wrote: > > > > 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 -~----------~----~----~----~------~----~------~--~---
