

Our TVF GetCourseListByStudentID returns columns from the Course table and so we can map the Course entity with the result instead of using a complex type. This will add TVF as a function and create a new complex type GetCourseListByStudentID_Result for the result. Make sure that the checkbox for Import selected procedures and functions into the entity model is checked (this will import the function automatically).

#Npoco idatabase updateasync update#
In the update wizard, expand the Stored Procedures and Functions -> Schema -> select GetCourseListByStudentID and click Finish. Where s.studentid = update your EDM and add this TVF into your exiting EDM by right clicking on the Designer -> select Update Model from the Database., as shown below. Left outer join course c on c.courseid = sc.courseid Add the SELECT statement with parameter references here select c.courseid, c.coursename,c.Location, c.TeacherIdįrom student s left outer join studentcourse sc on sc.studentid = s.studentid

Add the parameters for the function int */ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION. The following is a sample TVF GetCourseListByStudentID in SQL Server database, which will return all the courses of a particular student. Table-valued function is similar to the stored procedure, except for one key difference: the result of TVF is composable which means that it can be used in the LINQ-to-Entity query. Next Table-Valued Function in Entity Framework
