データベースのフィールド名をクラス名にマップする方法はたくさんありますが、アンダースコアを削除する最も単純な方法は何ですか?マッピング時にDapperにフィールド名のアンダースコアを無視/削除させる方法はありますか?
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; }
}
あなたはPostgreSQLのではなくSQL Serverを使用しているあなたは確かにいますか? – Andomar
はい。 :)あなたはコマンドタイプが "ストアドプロシージャ"であり、postgresqlが関数を持っているだけなので、あなたは尋ねていると思いますか?それはまだ動作します。 – scw