Skip to content

Self Reference Table With Composite Key #171

Open
@tigerhaolu727

Description

@tigerhaolu727

I just want to know if this is possible to do with fluent nhibernate.

I got a self reference table in my database.

Table Service
{
int Season (PK) (FK)
int Service_No (PK)
int ParentService_No (FK)
}

The table has a composite key as Season and Service_No, and Foreign Key for Self Reference as Season and ParentService_No

I try to create a collection property called ChildServices in my Service Class as many to many relations.

HasManyToMany(x => x.ChildServices )
.Table("SERVICE")
.Access.Property()
.AsBag()
.Cascade.SaveUpdate()
.LazyLoad()
.Generic()
.ParentKeyColumns.Add("SEASON")
.ParentKeyColumns.Add("SERVICE_NO")
.ChildKeyColumns.Add("SEASON")
.ChildKeyColumns.Add("P_SERVICE_NO");

If I use above mapping, it will throw my exception saying Repeated column in mapping for collection: Service.ChildServices column: SEASON

How can I do this? Is this a limitation of fluent nhibernate?

Thanks for answering my question.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions