Try it the other way round: Let Prices have many-to-ones to Product and
Store and query

from Price p where p.Product = :product and p.Store = :store

or if you have id's already

from Price p where p.Product.id = :productId and p.Store.id = :storeId

In the latter case, id must be lower case, see NH reference documentation.

-Markus

2009/8/27 [email protected] <[email protected]>

>
> Hi everyone,
>
> I have  the following setup - in a simplified view
>
> Products
> [ProductId] | Name
>
> Prices
> [ProductId] | [StoreId] | [PriceTier] | Price
>
>
> Columns in [] mark the PK.  So as you can see, Prices have a combined
> primary key based on the Product, the Store it counts for and the
> Price Tier (which is essentially something like "order 10 items, get
> cheaper price for it").
>
> To make everything work, I created a composite-id for Prices using the
> 3 columns defined as PK.
> (I know, that composite primary keys are not good, however in reality
> the Prices is as DatabaseView which joins together some information
> and therefor I do not have a realy column which I could use as a
> primary key)
>
> Also I have a one-to-many relation between Products an Prices setup
> using the ProductId only inside of a Bag.
>
> Using this code:
>            IQuery query = session.CreateQuery("from Product where Id
> = 63");
>            IList<Product> items = query.List<Product>();
>
> I get exactly one Product I wanted with a List of Price objects -
> which is pretty much what I wanted.
> However I get all Prices for all Stores, which is not what I want.
>
> So my final question on all what I told you now is: How would I query
> a given product and just retrieve the prices for a given Store
> (referenced by the StoreId?)
>
> Thanks,
> Philipp
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to