tags:

views:

46

answers:

1

I want to specify a column of my domain object which will be of Type Product lets say. Instead of this being a normal relationhip like one to one for example or one to many etc... I want this property to be a product, but also it is the most sold product.

So if I have an Object called ProductCategory

public class ProductCategory{
    public virtual Product BestSellingProduct{get;set;}
}

So my question is how can I integrate this logic into the mapping file for ProductCategory. I am not sure how the formule attribute of the property element could be used to return an object from the sql. Can HQL be used?

Andrew

+1  A: 

I wouldn't make BestSellingProduct a property on ProductCategory - I mean I would imagine a ProductCatalog that can answere to : get me the bestselling product for a category .

If you really want to use the property then you could do what section 13.4 says should be possible : Custom SQL for loading - nhibernate

sirrocco
Cheers that looks like the ticket!! :-)
REA_ANDREW
I'm glad it's what you need, but again - i'd advise against it. Best of luck
sirrocco
Yeh you are correct - Cheers :-)
REA_ANDREW