public ActionResult <IEnumerable <Professor> > Get()
        {
            var newProfessor = new Professor
            {
                ProfessorId = Guid.NewGuid()
            };

            var np = _collegeDbContext.Set <Professor>();

            np.Add(newProfessor);
            _collegeDbContext.Professors.Add(newProfessor);
            _collegeDbContext.SaveChanges();

            var professors = _collegeDbContext
                             .Professors
                             .AsNoTracking()
                             .OrderByDescending(x => x.ProfessorId)
                             .ToList();

            return(Ok(professors));
        }
Example #2
0
 public Repository(CollegeDbContext context)
 {
     Context = context;
     DbSet   = context.Set <TEntity>();
 }