执行存储过程报错,麻烦看下 返回

SqlSugar 老数据
10 1140
该叫什么   发布于2023/2/22
悬赏:5 飞吻

 请问下   这个参数我加了爆错,是我哪里操作不对吗

(H@WF1R37HT5]9_8Z@OOS(X.png

热忱回答10

  • fate sta fate sta VIP0
    2023/2/22

    db.ado.Use存储过程 ,少了个方法

    0 回复
  •     VIP0
    2023/2/22

    @fate sta:谢谢,就是存储过程中返回多个结果集,结果集字段相同,提示下面

    An element with the same key 'FlowTypeTitle' already exists in the ExpandoObject. Arg_ParamName_Name”这个有什么方法解决吗,或者说只能用getdataset那个?


    0 回复
  • fate sta fate sta VIP0
    2023/2/22

    你这个代码不像实体查询出的错

    0 回复
  • fate sta fate sta VIP0
    2023/2/22

      db.Ado.SqlQuery<Order>("select  1 as id,2 as id"); 目前我这样写是不报错的

    0 回复
  •     VIP0
    2023/2/22

    @fate sta:我这个是执行存储过程,不是查询sql,返回类似这样多个结果

    image.png

    0 回复
  • fate sta fate sta VIP0
    2023/2/22

    @ :映射那一块代码是一样的

    0 回复
  •     VIP0
    2023/2/22

    一样的,这个不能直接映射为集合吗?只能查询为 dataset 在遍历出来吗

    0 回复
  • fate sta fate sta VIP0
    2023/2/22

    image.png

    0 回复
  • fate sta fate sta VIP0
    2023/2/22

    没有问题,最新版本你还出错,就需提供完整DEMO了

        //create sp
         db.Ado.ExecuteCommand(@"
                        if object_id('up_user') is not null
                        drop proc up_user;");
         db.Ado.ExecuteCommand(@"     
                        create proc up_user
                        @id int,
                        @name varchar(10) ='' output
                        as
                   
                        begin
                           set @name='abc'
                           select @id as id,1 as id
                        end
                        ");
                //get output
      var dt3 = db.Ado.UseStoredProcedure().SqlQuery<Order>("up_user", new { name = "张三", id = 0 });


    0 回复
  •     VIP0
    2023/2/22

    谢谢,我明天试下

    0 回复