Dapper - Insert using nested object
问题 I have a class User with a nested class Bank . class User{ int Id; string username; Bank bank; } Class Bank{ int id; string name; } I need to create an Insert function for User . Is there a way in Dapper to execute a query and binding the parameters from a nested a object ? 回答1: You can write a custom mapper for Dapper using DapperExtensions : public sealed class UserMapper : ClassMapper<User> { public UserMapper() { Map(x => x.bank.id).Column("BankId"); Map(x => x.bank.name).Column("BankName