henkmollema / Dommel

CRUD operations with Dapper made simple.
MIT License
634 stars 100 forks source link

Multiple joins doubt #212

Closed hugofdsantos closed 4 years ago

hugofdsantos commented 4 years ago

Hello there, i'm trying to use this extension in conjunction with fluentmap.

I have a class with some properties:

public class Projeto : BaseEntity
 {
            public Cliente Cliente { get; set; }

            public int ClienteId { get; set; }

            public VerticalDeNegocio VerticalDeNegocio { get; set; }

            public int VerticalDeNegocioId { get; set; }
}

Basically, i'm trying to fetch all data using the Get method available on Dommel:

var p = Get<Projeto, Cliente, VerticalDeNegocio, Projeto>(id, (p, c, v) =>
            {
                p.Cliente = c;
                p.VerticalDeNegocio = v;
                return p;
            }); //Doesn't work

But i get the following error: Could not resolve foreign key property. Source type 'xx.xx.Cliente'; including type: 'xx.xx.VerticalDeNegocio'.

Is there some way to accomplish this join using this method? Looks like the method is trying to join the Id's from Cliente and VerticalDeNegocio, but what needs to be done is: Projeto and VerticalDeNegocio; Projeto and Cliente.

Besides that, if I query in a separate way, it works:

var p = Get<Projeto, Cliente, Projeto>(id, (p, c) =>
{
     p.Cliente = c;
     return p;
}); //Works

var x = Get<Projeto, VerticalDeNegocio, Projeto>(id, (p, v) =>
{
     p.VerticalDeNegocio = v;
     return p;
}); //Works

Thanks.

henkmollema commented 4 years ago

Which version of Dommel are you using?

hugofdsantos commented 4 years ago

Currently, I'm using v1.11.0 of Dommel.

henkmollema commented 4 years ago

Can you try this in Dommel 2.0?

henkmollema commented 4 years ago

Please re-open if the issue persists.