Dapper 插入时返回自增长id

var sql = @"INSERT INTO [MyTable] ([Stuff]) VALUES (@Stuff);";
sql += "SELECT CAST(SCOPE_IDENTITY() as int)";
var mytable = new MyTable();
mytable.Stuff = "test";

var id = connection.Query<int>(sql, mytable).FirstOrDefault();
展开阅读全文

没有更多推荐了,返回首页