sep24migrations.ViewModels.Repo_Subject.GetByIdWithProgram C# (CSharp) Method

GetByIdWithProgram() public method

Get one by its Id, and get some of its Program properties
public GetByIdWithProgram ( int id ) : SubjectWithProgram
id int Identifier
return SubjectWithProgram
        public SubjectWithProgram GetByIdWithProgram(int id)
        {
            // Note that we must .Include("Program") to fetch the associated object
            var subject = ds.Subjects.Include("Program").SingleOrDefault(i => i.Id == id);

            return (subject == null) ? null : Mapper.Map<SubjectWithProgram>(subject);
        }