码迷,mamicode.com
首页 > 其他好文 > 详细

EntityFramework 学习 一 Stored Procedure

时间:2017-03-25 23:22:40      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:param   getc   code   ges   tco   ons   src   div   get   

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);
}

 

EntityFramework 学习 一 Stored Procedure

标签:param   getc   code   ges   tco   ons   src   div   get   

原文地址:http://www.cnblogs.com/lanpingwang/p/6618963.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!