有很多方法可以将数据库字段名映射到类名,但是删除下划线最简单的方法是什么?
public IEnumerable<PersonResult> GetPerson(int personId)
{
using (var dbConnection = _dbConnectionFactory.Create(ConnectionStrings.ProjectXYZ))
{
IEnumerable<PersonResult> result =
dbConnection.Query<PersonResult>("fn_get_person", new { personId },
commandType: CommandType.StoredProcedure).ToList();
return result;
}
}
表和数据库字段:
person
--------
person_id
full_name
类:(dapper已经忽略了大写)
public class PersonResult
{
public int Person_Id { get; set; }
public string Full_Name { get; set; }
}
我想将课程改为:
public class PersonResult
{
public int PersonId { get; set; }
public string FullName { get; set; }
}