zoukankan      html  css  js  c++  java
  • EF 怎么调用存储过程并获得output参数

    1、MVC4的项目,自动会把存储过程在项目中映射为函数。

    2、存储过程:

      

     1 ALTER PROCEDURE [dbo].[P_FindAnZhiRen]
     2      @tempP_ID int output  
     3     ,@Member_ID int
     4     ,@Is_Right bit 
     5 AS
     6 
     7 
     8 set @tempP_ID =@Member_ID 
     9 BEGIN
    10 
    11 
    12 if @Is_Right =0
    13 begin
    14     While(Exists(select 1 from tbMemberInfo where Parent_ID=@tempP_ID and Is_Right=0))
    15     begin
    16         select @tempP_ID=Member_ID from tbMemberInfo where Parent_ID=@tempP_ID and Is_Right=0
    17     end     
    18 end 
    19 
    20 
    21 if @Is_Right =1
    22 begin
    23     if(Exists(select 1 from tbMemberInfo where Parent_ID=@tempP_ID and Is_Right=1))
    24     begin
    25         select @tempP_ID=Member_ID from tbMemberInfo where Parent_ID=@tempP_ID and Is_Right=1
    26     end
    27     
    28     While(Exists(select 1 from tbMemberInfo where Parent_ID=@tempP_ID and Is_Right=0))
    29     begin
    30         select @tempP_ID=Member_ID from tbMemberInfo where Parent_ID=@tempP_ID and Is_Right=0
    31     end     
    32 end 
    33 
    34 END

    项目代码:

      

                var tempP_ID = new ObjectParameter("tempP_ID", typeof(Int32));
                var result = db.P_FindAnZhiRen(tempP_ID, 1, false );
                var result1 = tempP_ID.Value;
    result1就是output的值
  • 相关阅读:
    Java 概述
    vue组件事件
    小程序注册
    小程序基础知识梳理
    小程序简介
    公众号
    jeecg-boot
    小程序背景图
    bootstrap-select采坑
    存取cookie
  • 原文地址:https://www.cnblogs.com/tider1999/p/4216179.html
Copyright © 2011-2022 走看看