Ramco Ramco

Ramco Ramco

  • 442
  • 3.4k
  • 528.7k

Display only few fields in Get method

Feb 17 2021 1:35 PM
Hi
 
I have below 2 classes . IN Controller Action method iwant to display only Id , Name , Email , Department Name in Get Method.
  1. public partial class Employee  
  2. {  
  3. public Employee()  
  4. {  
  5. CreatedOn = DateTime.Now;  
  6. }  
  7. public int ID { getset; }  
  8. public string Name { getset; }  
  9. public string Email { getset; }  
  10. public string Gender { getset; }  
  11. public Nullable<int> Salary { getset; }  
  12. public Nullable<int> DepartmentId { getset; }  
  13. public string Active { getset; }  
  14. [Display(Name = "Created On")]  
  15. [DataType(DataType.Date)]  
  16. [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]  
  17. public Nullable<System.DateTime> CreatedOn { getset; }  
  18. public Nullable<System.DateTime> UpdatedOn { getset; }  
  19. public virtual Department Department { getset; }  
  20. }  
  21. public int ID { getset; }  
  22. public string ShortName { getset; }  
  23. public string Description { getset; }  
  24. public virtual ICollection<Employee> Employees { getset; }  
Thanks

Answers (4)