<tfoot id='O3I86'></tfoot>
<legend id='O3I86'><style id='O3I86'><dir id='O3I86'><q id='O3I86'></q></dir></style></legend>

    1. <small id='O3I86'></small><noframes id='O3I86'>

      1. <i id='O3I86'><tr id='O3I86'><dt id='O3I86'><q id='O3I86'><span id='O3I86'><b id='O3I86'><form id='O3I86'><ins id='O3I86'></ins><ul id='O3I86'></ul><sub id='O3I86'></sub></form><legend id='O3I86'></legend><bdo id='O3I86'><pre id='O3I86'><center id='O3I86'></center></pre></bdo></b><th id='O3I86'></th></span></q></dt></tr></i><div id='O3I86'><tfoot id='O3I86'></tfoot><dl id='O3I86'><fieldset id='O3I86'></fieldset></dl></div>
          <bdo id='O3I86'></bdo><ul id='O3I86'></ul>

        Dapper.NET 和具有多个结果集的存储过程

        时间:2023-10-26
        <i id='LqIAK'><tr id='LqIAK'><dt id='LqIAK'><q id='LqIAK'><span id='LqIAK'><b id='LqIAK'><form id='LqIAK'><ins id='LqIAK'></ins><ul id='LqIAK'></ul><sub id='LqIAK'></sub></form><legend id='LqIAK'></legend><bdo id='LqIAK'><pre id='LqIAK'><center id='LqIAK'></center></pre></bdo></b><th id='LqIAK'></th></span></q></dt></tr></i><div id='LqIAK'><tfoot id='LqIAK'></tfoot><dl id='LqIAK'><fieldset id='LqIAK'></fieldset></dl></div>

          • <bdo id='LqIAK'></bdo><ul id='LqIAK'></ul>

              <small id='LqIAK'></small><noframes id='LqIAK'>

                <tbody id='LqIAK'></tbody>
              • <legend id='LqIAK'><style id='LqIAK'><dir id='LqIAK'><q id='LqIAK'></q></dir></style></legend>
                1. <tfoot id='LqIAK'></tfoot>
                2. 本文介绍了Dapper.NET 和具有多个结果集的存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有办法将 Dapper.NET 与返回多个结果集的存储过程一起使用?

                  Is there any way to use Dapper.NET with stored procs that return multiple result sets?

                  就我而言,第一个结果集是单行单列;如果它是 0 则调用成功,第二个结果集将包含实际的数据行/列.(如果它不为零,则会发生错误并且不会提供第二个结果集)

                  In my case, the first result set is a single row with a single column; if it's 0 then the call was successful, and the second result set will contain that actual rows/columns of data. (and if it was non-zero, an error occured and no second result set will be provided)

                  有机会用 Dapper.NET 处理这个问题吗?到目前为止,我只取回了那个 0 - 但仅此而已.

                  Any chance to handle this with Dapper.NET? So far, I'm only ever getting back that single 0 - but nothing more.

                  更新: 好的,它工作正常 - 只要结果集没有.2 是单个实体:

                  Update: OK, it works fine - as long as the result set no. 2 is a single entity:

                  Dapper.SqlMapper.GridReader reader = 
                      _conn.QueryMultiple("sprocname", dynParams, 
                      commandType: CommandType.StoredProcedure);
                  
                  int status = reader.Read<int>().FirstOrDefault();
                  MyEntityType resultObj = reader.Read<MyEntityType>().FirstOrDefault();
                  

                  现在,我有另一个要求.

                  第二个结果集的 Dapper 多映射(将从 SQL Server 返回的单行拆分为两个单独的实体)似乎尚未得到支持(至少似乎没有过载.Read 可以处理多映射).

                  Dapper's multi-mapping (splitting up a single row returned from SQL Server into two separate entities) for that second result set doesn't seem to be supported as of yet (at least there doesn't seem to be an overload of .Read<T> that can handle multi-mapping).

                  如何将该行拆分为两个实体?

                  How can I get split that row into two entities?

                  推荐答案

                  您是否尝试过 QueryMultiple 方法?它说它应该:

                  Have you tried the QueryMultiple method? It says it should:

                  执行返回的命令多个结果集,并访问每个依次

                  Execute a command that returns multiple result sets, and access each in turn

                  您需要添加此 using 语句以启用 QueryMultiple .

                  You'll need to add this using statement to enable QueryMultiple .

                  using Dapper; /* to add extended method QueryMultiple public static GridReader QueryMultiple(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null); */
                  

                  这篇关于Dapper.NET 和具有多个结果集的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:不使用游标的每一行的 SQL 调用存储过程 下一篇:SQL Server 以静默方式截断存储过程中的 varchar

                  相关文章

                  <legend id='2tmxf'><style id='2tmxf'><dir id='2tmxf'><q id='2tmxf'></q></dir></style></legend>
                3. <small id='2tmxf'></small><noframes id='2tmxf'>

                        <bdo id='2tmxf'></bdo><ul id='2tmxf'></ul>
                      <i id='2tmxf'><tr id='2tmxf'><dt id='2tmxf'><q id='2tmxf'><span id='2tmxf'><b id='2tmxf'><form id='2tmxf'><ins id='2tmxf'></ins><ul id='2tmxf'></ul><sub id='2tmxf'></sub></form><legend id='2tmxf'></legend><bdo id='2tmxf'><pre id='2tmxf'><center id='2tmxf'></center></pre></bdo></b><th id='2tmxf'></th></span></q></dt></tr></i><div id='2tmxf'><tfoot id='2tmxf'></tfoot><dl id='2tmxf'><fieldset id='2tmxf'></fieldset></dl></div>

                    1. <tfoot id='2tmxf'></tfoot>