zoukankan      html  css  js  c++  java
  • Dapper 返回存储过程值

    using (IDbConnection conn = WebDbConn.DbService()) {
    conn.Execute(@"
    create proc #TestOutputParameterProc @Foo int, @Bar int out as
    set @Bar = @Foo select 1 as [A] select 2 as [B]");
    try
    {
    var args = new DynamicParameters(new { Foo = 123 });
    args.Add("@Bar", dbType: DbType.Int32,
    direction: ParameterDirection.Output);
    using (var grids = conn.QueryMultiple("#TestOutputParameterProc",
    args, commandType: CommandType.StoredProcedure))
    {
    // this will fail here; we have not consumed the TDS data yet!
    // args.Get<int>("@Bar").IsEqualTo(123);

    // note we don't *have* to read the data here; disposing "grids"
    // would be enough to skip to the end of the TDS
    //var A=grids.Read<int>().Single().Equals(1); // A
    //var B=grids.Read<int>().Single().Equals(2); // B
    var A = grids.Read<int>().Single(); // A
    var B = grids.Read<int>().Single(); // B

    }
    // at this point we have consumed the TDS data, so the parameter
    // values have come back to the caller
    args.Get<int>("@Bar").Equals(123);
    }
    finally
    { // clean up the proc
    conn.Execute("drop proc #TestOutputParameterProc");
    }

    存储过程返回值
    http://stackoverflow.com/questions/9870969/can-dapper-return-values-from-a-sql-function/9871380#9871380
    http://stackoverflow.com/questions/14723277/dapper-output-parameter-is-not-returning-values/14746522#14746522

  • 相关阅读:
    js排序算法01——冒泡排序
    Math Issues
    2017年终总结
    js中的真值和假值
    element UI 中DateTimePicker 回传时间选择
    Equal Sides Of An Array
    javascript数组总结(0504)
    ajax生成html双引号问题
    关于php ci框架ie浏览器路径问题
    ie提示jquer缺少标识符,字符串或数字
  • 原文地址:https://www.cnblogs.com/ggbbeyou/p/2957645.html
Copyright © 2011-2022 走看看