Sorry, you managed to catch this in the 2 minutes before I deleted it. We had made a careless error and had the relationship on TWO properties in the same class-- IE:
public IList<TicketNote> TicketNotes public IList<TicketNote> Notes And of course I found this 2 minutes after I posted, so I deleted it hoping to save everyone the trouble. On Sep 12, 4:35 pm, Patrick Steele <[email protected]> wrote: > The TicketNotes must be virtual and (IIRC) you have to set "Lazy = > true" on the [ActiveRecord] attribute for the class. > > -- > Patrick Steelehttp://weblogs.asp.net/psteele > > On Sat, Sep 12, 2009 at 11:53 AM, JakeS <[email protected]> wrote: > > > I have a User entity that has a collection of Tickets. Each ticket > > has a collection of TicketNotes. When I run a query to get open > > tickets associated with the user, it's fetching every note even though > > I'm not accessing that property: > > > public Ticket[] OpenTickets > > { > > get > > { > > return Ticket.FindAll( > > new ICriterion[] > > { > > Restrictions.Eq("AssignedCSR", this), //Associated > > with this user > > Restrictions.Not( // > > Any ticket that's not scheduled or completed > > Restrictions.Disjunction().Add( > > Restrictions.Eq("Status", > > TicketStatus.Completed)).Add( > > Restrictions.Eq("Status", > > TicketStatus.Scheduled)) > > ) > > } > > ); > > } > > } > > > Inside the ticket class I have this: > > > private IList<TicketNote> _ticketNotes; > > [HasMany(typeof(TicketNote),Lazy=true)] > > public IList<TicketNote> TicketNotes > > { > > get > > { > > if(_ticketNotes==null){_ticketNotes = new List<TicketNote>();} > > return _ticketNotes; > > } > > set { _ticketNotes = value; } > > } > > > So even though TicketNote is set so Lazy=true, and I'm not using the > > TicketNote property in for this, it's still running "SELECT ... FROM > > TicketNote..." for each open ticket. > > > What could I be missing? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
