/// <summary>
/// 获取表tb_sys_zhuowei全部数据
/// </summary>
public IEnumerable<Model_tb_sys_zhuowei> SelectAll_tb_sys_zhuowei()
{
using (IDbConnection conn = OpenConnection())
{
const string query = @"select from tb_sys_zhuowei order by addtime desc";
return connQuery<Model_tb_sys_zhuowei>(query, null);
}
}
dapper 返回Sql server 自增长ID 标识列SCOPE_IDENTITY
SQL获取刚插入的记录的自动增长列ID的值
CREATE TABLE [dbo][MesTest](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Msg] [nvarchar](500) NULL
) ON [PRIMARY]
[TestMethod]
public void TestMethod1()
{
var sql = "INSERT INTO [MesTest] ([Msg]) VALUES('ss');SELECT @id=SCOPE_IDENTITY()";
using (var db = DatabaseDbService)
{
var p = new DynamicParameters();
pAdd("@ID", dbType: DbTypeInt32, direction: ParameterDirectionOutput);
var i = dbExecute(sql,p);
var i1 = pGet<int>("@ID");
AssertInconclusive(i1ToString());
}
}
dapper 返回Sql server 自增长ID 标识列SCOPE_IDENTITY
SQL获取刚插入的记录的自动增长列ID的值
CREATE TABLE [dbo][MesTest](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Msg] [nvarchar](500) NULL
) ON [PRIMARY]
[TestMethod]
public void TestMethod1()
{
var sql = "INSERT INTO [MesTest] ([Msg]) VALUES('ss');SELECT @id=SCOPE_IDENTITY()";
using (var db = DatabaseDbService)
{
var p = new DynamicParameters();
pAdd("@ID", dbType: DbTypeInt32, direction: ParameterDirectionOutput);
var i = dbExecute(sql,p);
var i1 = pGet<int>("@ID");
AssertInconclusive(i1ToString());
}
}
以上就是关于如何将dapper生成json全部的内容,包括:如何将dapper生成json、如何在dapper中获取刚插入行的ID、DapperExtensions 怎么才能获取它生成的Sql语句等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)