public static void GetCourseDetailByInstructor(int id) { using (var context = new EnrollmentContext()) { //var stats = context.CourseDetails // .FromSqlRaw("EXEC GetCourseByInstructor {0}", id) // .ToList(); //stats.ForEach(st => Console.WriteLine($"{st.Title} - by {st.Name}, Number of students: {st.NumOfEnrolledStudents}")); var stats = context.Set <CourseDetail>() .FromSqlRaw("EXEC GetCourseByInstructor {0}", id) .ToList(); stats.ForEach(st => Console.WriteLine($"{st.Title} - by {st.Name}, Number of students: {st.NumOfEnrolledStudents}")); } }
public virtual async Task <T> GetByIdAsync(int id, CancellationToken cancellationToken = default) { var keyValues = new object[] { id }; return(await DbContext.Set <T>().FindAsync(keyValues, cancellationToken)); }