Hi all,

I have a question about mapping a small part of a database schema.  I
have a solution, but I think it is sub-optimal and I am looking for
other ideas.

I have a product lines class (ProductLine) which can hold child
product lines.

    public class ProductLine
    {
        public virtual ProductLine Parent { get; set; }
        public virtual ICollection<ProductLine> Children { get; set; }
        public virtual Manufacturer Manufacturer {get; set;}
    }

Nothing unusual here. Pretty standard stuff.  I also have  a
Manufacturer Class that looks like this.

    public class Manufacturer
    {
        public virtual ICollection<ProductLine> ProductLines { get;
set; }
    }

What I am looking for is that a manufacturer can has multiple product
lines, each of which can have its own child product lines. i.e

    m
        pl1 (Manufacturer parent - m)
            pl1a (Manufacturer parent - null)
            pl1b (Manufacturer parent - null)
        pl2 (Manufacturer parent - m)
            pl2a (Manufacturer parent - null)
                pl2a1 (Manufacturer parent - null)
        pl3 (Manufacturer parent - m)

As can be seen from the above diagram I want all child product lines
to have their many to one manufacturer associations set. The only
product lines which have their manufacturer property set is when I add
them to the product lines collection in the manufacturer class.

I have got a solution which works by accessing the Manufacturer
property (which is set to access="field.camelcase-underscore") and if
it set to null then move up the tree until we reach the root product
line and I can get the manufacturer from there. Hope that makes sense!

But this could potentially call the database many times during a
session as we recursively go up the tree.  I have not posted my
mapping files and complete code as it could make the post very long. I
am happy to do so if required.

Any other ideas would be gratefully received.

Best of regards

Mohammad

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