views:

216

answers:

2

I have a table A that has a references to a table B through a third table C. C contains the primary key of A and B. For each A there is at most one record in C. When I try to create a mapping for A such that I am referencing B, I use the References function, but it does not allow me to specify that the mapping goes through another table and not directly. What is the proper way to do that?

A: 

The only mapping that I know that could do that would be a HasManyToMany in the mapping of A :

HasManyToMany(x => x.B)
    .WithTableName("C")
    .WithParentKeyColumn("A_Id")  
    .WithChildKeyColumn("B_Id");

The problem is that the mapping is for A having a list of Bs, not just one. I don't know how you could do it to get only one in a clean way.

gcores
A: 

I believe I have found the answer in google code samples. In the mapping class, it is possible to write an additional:

WithTable("SomeTable", c => { c.Map(x => x.Col1); });
eulerfx