Thanks for your help,i will make a try tonight,and post my response
here later on:)
Thanks again!

On Jan 30, 5:21 am, James Gregory <jagregory....@gmail.com> wrote:
> Well, the Where statement is now mapped.
> If ObjType is in your class (and you are using the default column name) you
> can do this:
>
> HasMany<Comment>(x => x.Comments)
>   .Where(x => x.ObjType == "Product");
>
> If it isn't in your object, or it is but the name differs from the database
> column, then you should do this instead:
>
> HasMany<Comment>(x => x.Comments)
>   .Where("ObjType = 'Product'");
>
> On Wed, Jan 28, 2009 at 12:36 PM, James Gregory 
> <jagregory....@gmail.com>wrote:
>
> > I'm not entirely sure how you'd map this using standard hbm, but I think
> > it'd probably involve the where attribute on the collection. We currently
> > don't explicitly support where, so you'll have to fudge it. I'd do it
> > something like:
> > public class CommentMap : ClassMap<Comment>
> > {
> >   public CommentMap()
> >   {
> >     // comment fields
> >   }
> > }
>
> > // and the same for Post
> > public class ProductMap : ClassMap<Product>
> > {
> >   public ProductMap()
> >   {
> >     // mappings
> >     HasMany<Comment>(x => x.Comments)
> >       .SetAttribute("where", "ObjType = 'Product'");
> >   }
> > }
>
> > The contents of the where attribute may vary depending on what your column
> > actually contains.
>
> > On Wed, Jan 28, 2009 at 3:15 AM, Levin <cocoay...@gmail.com> wrote:
>
> >> Happy new year guys,
> >>   I don't know how to map these tables(as below),any help will be
> >> appreciated.
> >>   Tables are:
> >>   1,Posts
> >>   2,Products
> >>   3,ObjComments
>
> >>   We need to save those comments on Posts(Or Products) in the
> >> ObjComments table,so there are two special columns 'ObjType' and
> >> 'ObjID' in the ObjComments table.Obviously,ObjType is an enum composed
> >> with 'Post' and 'Product',when ObjID is the post's(or products)
> >> primary key.
> >>   My question is,how to map these three tables?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to