I have two bunch of code which I'm trying to understand properly but still don't see why they use new CompanyDto in the second code snippet. 

and why they didn't use new User in the below/first code snippet like var selectedData = _context.User.Select(x => new User

So what's really the difference between these two lines ?

public class User
    {
        public Guid Id { get; set; }
        public string Name { get; set; }
        public string Department { get; set; }
        public string photo { get; set; }
    }
    
    public virtual DbSet<User> User { get; set; }

    public IActionResult GetUsersList()
    {
        var selectedData = _context.User.Select(x => new
        {
            id = x.Id,
            name = x.Name
        });
return Json(selectedData); }
                                public class CompanyDto
				{
					public Guid Id { get; set; }
					public string Name { get; set; }
					public string FullAddress { get; set; }
				}
				
				public IActionResult GetCompanies()
				{
					var companies = _repository.Company.GetAllCompanies(trackChanges: false);

					var companiesDto = companies.Select(c => new CompanyDto
					{
						Id = c.Id,
						Name = c.Name,
						FullAddress = c.Address
					}).ToList();
					
					return Ok(companiesDto);				
				}