DapperLib / DapperAOT

Build time tools in the flavor of Dapper
Other
349 stars 19 forks source link

Mapping inherited class properties #93

Closed shiomax closed 7 months ago

shiomax commented 8 months ago

Right now when using a base class for your entities like this

public abstract class EntityBase
{
    public long Id { get; set; }
}

public class Entity1 : EntityBase
{
    public string Name { get; set; }
}

Then the Id property will not be read by the code generated.

It only works when putting the Id directly into Entity1 (otherwise it never gets mapped, always default 0 for any query). I think it´s fairly common to want to enforce consistent naming of ids and timestamps. Although, this can be enforced with interfaces too I suppose (doing that now instead).

The above should either work, or a the analyzer should give you a warning about this (in case this is not gonna be implemented anytime soon). I don´t yet know enough about compile time generators to know how hard it is to figure out that there is a base class and walk back up the class tree.

mgravell commented 7 months ago

agreed, this should work; will get to it

JerryJian commented 5 months ago

Hello, when will this fix be released, thanks?