在Dapper.DefaultTypeMap.MatchNamesWithUnderscores
不工作的刀片。映射器可以很好地使用该Get<>
方法。我在ASP.NET Core 1.0 RC2项目中使用以下版本以及postgres数据库。
"dependencies": {
"Dapper": "1.50.0-rc2",
"Dapper.Contrib": "1.50.0-beta8"
}
程式码片段
using (var conn = new NpgsqlConnection("connString"))
{
conn.Open();
Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true;
long id = conn.Insert(new Foo { Name = "new foo", LocationId = 3});
return id;
}
已执行的插入SQL处理
insert into foo ("Name", "LocationId") values ($1, $2) RETURNING Id
富班
[Dapper.Contrib.Extensions.Table("foo")]
public class Foo
{
public int Id { get; set; }
public string Name { get; set; }
public int LocationId { get; set; }
}
脚桌
CREATE TABLE "foo" (
"id" SERIAL PRIMARY KEY,
"name" VARCHAR(100) NOT NULL,
"location_id" INTEGER REFERENCES "location" (id)
);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句