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

 

 

EntityFramework 学习 一  Stored Procedure

 

 EntityFramework 学习 一  Stored Procedure

 

 EntityFramework 学习 一  Stored Procedure

 

 EntityFramework 学习 一  Stored Procedure

 

 EntityFramework 学习 一  Stored Procedure

 

 EntityFramework 学习 一  Stored Procedure

 

 EntityFramework 学习 一  Stored Procedure

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

    foreach (Course cs in courses)
        Console.WriteLine(cs.CourseName);
}

 

相关文章:

  • 2021-07-17
  • 2022-01-24
  • 2021-06-06
  • 2021-07-10
  • 2021-06-19
  • 2021-05-17
  • 2021-10-06
猜你喜欢
  • 2022-01-08
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2022-01-03
相关资源
相似解决方案