I am converting a desktop application from code that manually executes SQL statements etc. to NHibernate. I am following the philosophy that Ayende shows in his To Do List application. However, I am having issues with binding a DataGridViewComboBoxColumn to a list of objects returned from the NHibernate ISession.
In the main GUI the user selects the Item they want to work with. When they select the Item, another GUI opens up with its own ISession. This session is disposed of once the user is done using the Item editing GUI. This GUI allows the user to select a Report, which will then show potentially hundreds of ReportItems in a DGV. These ReportItems have references to other objects so I have pre-queried all the lookup lists. Before I even query for the Item in question, I query all of the Owners (approximately 8), as well as everything else I need. Because there are not many items in the 4-5 look-up lists, I figured it would be better to pre-fetch them than to have the ReportItems or Reports get them lazily. The problem is that one of the columns the user is allowed to edit (Owner) is a ComboBoxColumn. They are allowed to pick from the list to change what the owner of the ReportItem should be. This causes issues because the IList(of Owner) returned by NHibernate contains some OwnerProxy objects, and some Owner objects. I have tried all methods of eager loading and fetching, but I still get a mixed set of object types. I have seen a solution to this here: http://code.google.com/p/systembusinessobjects/source/browse/trunk/System.BusinessObjects.Framework/Data/SafeBindingLists.cs . This code basically takes an IList from NHibernate and makes sure that it contains all proxy objects, or all regular objects. Unfortunately, this code seems to be for an older version of NHibernate (I'm using 3.2.0.4) and the code relies on the Castle proxy generator. Is there a more elegant solution to this now? Or is there perhaps a way to get around the Castle dependency in that code? I look forward to your help, and thank you in advance. I have been beating my head against the wall on this for a while. -- 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.
