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的值
  • 相关阅读:
    tcp三次握手和四次挥手
    tcp/ip五层协议
    osi七层模型
    函数与模块间作用域的区别
    简易版学生选课系统
    用pathon实现计算器功能
    python三大神器之生成器
    python三大神器之迭代器
    用python实现购物车功能
    正则表达式用法简介
  • 原文地址:https://www.cnblogs.com/tider1999/p/4216179.html
Copyright © 2011-2022 走看看