Dapper-FluentMap
Dapper-FluentMap copied to clipboard
Mapping problem with subclass
Sample for this case
First is super class like below
public class User
{
public string UserId { get; set; }
public string Email { get; set; }
}
Second is subclass like below
public class AdminUser : User
{
public int Role { get; set; }
}
Than i create mapper and initial mapper
public class UserMap : EntityMap<User>
{
public UserMap()
{
Map(c => c.UserId).ToColumn("user_id");
}
}
FluentMapper.Initialize(config =>
{
config.AddMap(new UserMap());
}
Everything work as properly when i set return type is User
in query
But when i try to change return type from User
to AdminUser
in the same query it look like mapping doesn't work, UserId become null.
Is any some extra work for this solution ?
You'll need to create a mapping for AdminUser
as well.
I'm archiving this repository as I'm not using this library myself anymore and have no time maintaining it. Thanks for using it.