Hi,
I'm new to NHibernate and am I am working with a asp.net mvc web application.
I have a PhoneNumber object that has an object called PhoneType representing items like "Work", "Home", "Mobile" etc. The PhoneTypeId has an Id and Name property. I need to update the PhoneTypeId on the PhoneNumber when a change has been made from a UI dropdownlist.
I will automatically have access to the PhoneTypeId when the form posts, but not the Name. To update the PhoneTypeId I assume that I must do something like the following:
phone.PhoneType.PhoneTypeId = drodownlistvalue;
But what about the Name value? Do both the Id and Name values need to be updated to save the correct PhoneTypeId on the PhoneNumber? I'm concerned about the need to make another db call just to get the Name or the need to cache the PhoneTypes collection into the HTTP SESSION. An object with many similar relationships starts getting really inefficient. Let's say an AddressType, State/Region, and Country were all needed in dropdowns for an Address object. What is the recommended practice for NHibernate?
Thanks, Mark
|