Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self Reference Table With Composite Key #171

Open
tigerhaolu727 opened this issue Oct 2, 2012 · 0 comments
Open

Self Reference Table With Composite Key #171

tigerhaolu727 opened this issue Oct 2, 2012 · 0 comments

Comments

@tigerhaolu727
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant