I'm working on a Winforms app with NHibernate as my ORM layer. Everything is going well, but it doesn't seem that NHibernate is respecting my instructions to not use lazy loading.
Problem 1:
The app is a task list type of thing, and tasks can have child tasks. I'm representing these in a TreeView, so I need to first add nodes for top-level tasks, then check if those tasks have children, and move on. I can't see any way that I can check for children without making repeated hits to the database, even though I'm loading every task (regardless of parent or child status) with an initial call. At first I was looping through the Children property of each task, and I guess I can see why that would require a query for each; however, I attempted to optimize by looping through all tasks and checking for equality between a tasks parent and the task whose children I'm looking for, and that still hits the database each time around.
Problem 2 (perhaps the more easily solvable or answerable one):
The app supports attachments for tasks. When a project is selected and all of the tasks for that project are loaded, NHibernate is issuing a separate select query to get the attachment data, even though I have lazy set to false and fetch set to join.
So, am I misunderstanding how to set up my properties in my mapping files, or is this a limitation in SqlCe, or is it something else entirely?
Always grateful for the help, Brian
UPDATE
I know that mapping definitions would be helpful, but I work for a large corporation and I don't want to post anything specific from the project.
I can abstractly tell you that there is a domain object for a Task, and that the ParentId field is the column used in the many-to-one element for the relationship between tasks. Additionally, the attachments relationship in the Task map is a set with a key column of TaskId and a one-to-many definition related to the class Attachment.
Hope that helps, sorry I can't post the maps.