How to map an identity column, that has a different name, with Dapper?

孤者浪人 提交于 2019-12-01 05:13:25

By design, dapper does not have a mapping layer. One step down that road, and before we know what has happened all of a sudden we'll be drowning in configuration files. So: two options:

  • add an alias in the SQL
  • add a shim in the C#

so either (sql):

select BookId as [Id], Name from Books

or (C#):

private int BookId { get { return Id; } set { Id = value; } } // just for dapper
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!