EntityFramework 学习 一 Stored Procedure

CREATE PROCEDURE [dbo].[GetCoursesByStudentId]
    -- Add the parameters for the stored procedure here
    @StudentId int = null
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
select c.courseid, c.coursename,c.Location, c.TeacherId
from student s
left outer join studentcourse sc on sc.studentid = s.studentid
left outer join course c on c.courseid = sc.courseid
where s.studentid = @StudentId
END

using (var context = new SchoolDBEntities())
{
    var courses = context.GetCoursesByStudentId(1);

    foreach (Course cs in courses)
        Console.WriteLine(cs.CourseName);
}
时间: 2024-08-06 11:56:16

EntityFramework 学习 一 Stored Procedure的相关文章

[LINQ] 如何调用 Stored Procedure From EntityFramework (2)

摘要:[LINQ] 如何调用 Stored Procedure From EntityFramework (2) 这次要说的是另一种读取方式,但是首先还是将Stored Procedure 加入Entity Model 如何加入请参考第一篇 :?http://www.dotblogs.com.tw/constancy/archive/2013/10/31/126285.aspx 加入完之后,可用以下方式取得数据 EntityConnection entityConnection = (Entit

Oracle Stored Procedure demo

1.how to find invalid status stored procedure and recompile them? SELECT OBJECT_NAME , status FROM user_objects WHERE OBJECT_TYPE = 'PROCEDURE'; Alter procedure schme.procedurename compile; 缺少练习的学习不是完整的学习,练习才是学习,总结才有思考.   SELECT OBJECT_NAME , STATUS

【机房重构】——存储过程(Stored Procedure)

[前言] 在学习数据库知识时,就曾经接触过存储过程,当时只是如蜻蜓点水一般,短暂的停留,并没有留下什么印象,在进行机房重构学习过程中,又重新认识了存储结构,从开始的抵触,不想用到后来逐渐了解,学着使用,思路越来越清晰,真正去做了才发现了其中的乐趣:常常说学习需要多总结,现在就是在积累,每一次的收获都要整理记录,才能留下深刻的印象,下面就来学习一下存储过程的知识吧. [存储过程的概念] 在采用客户机/服务器(C/S)计算模式的数据库系统中,很多工作可以在客户端完成,也可以在服务器端完成,数据库除了

Publishing Stored Procedure Execution in Transactional Replication

Replication 不仅可以将Table Article 或 SP Article 推送到subscription,而且还能将sp的execution推送到subscription.推送sp的execution是指将执行sp的command 推送到subscriber去执行, 而不是将sp执行之后产生的大量transaction推送到subscriber上.Transaction是逐个更新Table Article中的数据行. 推送sp的execution来同步subscription的数据

在JDBC中传递table参数给SQL server stored procedure

SQL Server JDBC驱动不支持直接传递Table参数给stored procedure 我的做法是先创建一个临时表,将需要插入的数据先插入到临时表里面,然后把这个临时表作为参数,传送给stored procedure.使用了Preparestatement来避免SQL注入问题. 先创建User Defined Table CREATE TYPE UserIdList AS TABLE( userId uniqueidentifier NOT NULL ); 再创建存储过程: CREAT

Stored Procedure 里的 WITH RECOMPILE 到底是干麻的?

原文:Stored Procedure 里的 WITH RECOMPILE 到底是干麻的? 在 SQL Server 创建或修改「存储过程(stored procedure)」时,可加上 WITH RECOMPILE 选项,但多数文档或书籍都写得语焉不详,或只解释为「每次执行此存储过程时,都要重新编译」.事实上,是指执行此一存储过程时,要强制重新产生「执行计划(execution plan)」,而不要从「缓存(cache)」去取得旧的「执行计划」. SQL Server 在评估与产生「执行计划」

SQL Server 在多个数据库中创建同一个存储过程(Create Same Stored Procedure in All Databases)

原文:SQL Server 在多个数据库中创建同一个存储过程(Create Same Stored Procedure in All Databases) 一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 遇到的问题(Problems) 实现代码(SQL Codes) 方法一:拼接SQL: 方法二:调用模板存储过程创建存储过程: 总结 扩展阅读 参考文献(References) 二.背景(Contexts) 在我的数据库服务器上,同一个实例

Retrieving Out Params From a Stored Procedure With Python

http://www.rodneyoliver.com/blog/2013/08/08/retrieving-out-params-from-a-stored-procedure-with-python/ AUG 8TH, 2013 I was hacking some python today which calls a stored procedure that sends back an out parameter to indicate whether or not it complet

Oracle Java Stored Procedure + 包调用

1. 创建Java Stored Procedure create or replace and compile java source named "TestHello" as public class TestHello{   public static void test(){     System.out.println("Hello");   } } 2.创建JSP调用存过或方法(本例为在包创建的存过) create or replace package