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