Fluent Nhibernate - One to Many Mapping - Child of same type as Parent
I have a class defined as:
public class ReportClient
{
public virtual int? Id { get; set; }
public virtual long? ClientId { get; set; }
public virtual 开发者_开发百科string Name { get; set; }
public virtual string EmailAddress { get; set; }
public virtual string AdditionalEmailAddress { get; set; }
public virtual List<ReportClient> ChildClients { get; set; }
}
As you can see ChildClients are of same type as Parent.
Please guide me how can I map 'ChildClients' so for each ChildClient in List<ReportClient> ChildClients
there is a new table record with a column 'ParentId' being set for this record ( having ParentId = Id)
Please guide.
Thank you!
I don't have the enviroment to test, but this should work, try swapping the column names if it doesn't.
HasManyToMany(x => x.ChildClients)
.ParentKeyColumn("ParentId")
.ChildKeyColumn("Id")
精彩评论