我有以下代码
class Program
{
static void Main(string[] args)
{
static void Main(string[] args)
{
DapperExtensions.DapperExtensions.DefaultMapper = typeof(CodeCustomMapper);
string sql = "select UserID,Name as SName , Email ,Email as wmail from dbo.[User]";
using (SqlConnection connection = new SqlConnection(conn))
{
var result = connection.Query<User>(sql
, commandType: CommandType.Text);
}
}
}
public class CodeCustomMapper: ClassMapper<User>
{
public CodeCustomMapper()
{
base.Table("User");
Map(f => f.UserID).Key(KeyType.Identity);
Map(f => f.Name).Column("SName");
Map(f => f.Name).Column("TName");
Map(f => f.EmailID).Column("wmail");
Map(f => f.EmailID).Column("Email");
}
}
手动映射列的输出为 NULL。即使我已经分配了默认映射器。是写方式吗?
使用实体属性手动映射数据库列的任何其他方式?
请问有人可以帮忙吗