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

  • 相关阅读:
    iOS-导航条
    iOS-存储
    iOS-模型传递
    iOS-日期相关
    iOS-UIViewController
    iOS-loadView方法
    iOS-UIWindow
    Spring 测试
    Spring条件注解@Conditional
    Spring多线程
  • 原文地址:https://www.cnblogs.com/ggbbeyou/p/2957645.html
Copyright © 2011-2022 走看看