1.不含动态sql、带输出参数存储过程调用实例
1.存储过程代码:


3.调用存储过程代码实例:

- ObjectParameter参数对应输出类型时,不必指定类似Output等
- ObjectParameter的命名空间:using System.Data.Objects;
- ObjectParameter参数的Name是对应存储过程参数字符串去掉@符号,
- 例如存储过程参数‘@Count int output‘,对应Name为”Count“,注意不区分大小写
此处注意ToList(),延迟加载 否则count查不出来
2.动态sql、带输出参数存储过程调用实例
1.存储过程代码:

2.EF自动生成代码(不可用):

3.存储过程调用代码:

总结:
- 对于动态sql的存储过程需要使用SqlQuery方法,并且对应的参数应为SqlParameter类型
- 对于非动态sql的存储过程EF自动生成对应的方法和返回结果的实体类,对应的参数类型为ObjectParameter