jchapman wrote:
First, do you really need to use stored procedures? I assume you do this because it is a company policy? The application will perform better if you allow it to write the dynamic sql. Development time would also be greatly reduced. I realize this may not be an option.
Yes, our standard is to use stored procs, but I have relaxed that requirement a bit by letting NHibernate generate the query when it is a simple fetch, or a simple join on a foreign key. This particular query is a little more involved so I prefer to implement it as a stored proc.
jchapman wrote:
Second, you could use a "reporting object" to encapsulate just the fields you want to return. So make a new object which is named something like ProductPriceList which has a child Price property and child CurrencyPrice property. (Of course you would also include any other columns you needed). This will then let you use just one query to populate all values, but if you ever needed to modify the price or currency you would still need to do a load from the database for that record. The "reporting object" would not be an object which mapped directly to any table, it would just be used to return the results of the stored procedure.
The ProductPrice object already has the schema that I want to use. I could create another object that flattens the ProductPrice and Currency fields into a single object, but this is ugly.
My stored procedure returns the following fields:
ProductID
CurrencyCode
CurrencyName
CurrencySymbol
CurrencyUsdValue
Price
Can I not group the Currency* fields into a Currency object? Can I map them to a Currency component?