2

If i have a set of Entities (Classes) like this :

Employee, Department, Room ... etc

How to add these classes to a list instead of a list of objects :

Like this :

{Employee, Department, Room}

I want to get these classes because i have a method with the following signature :

AuditManager.DefaultConfiguration.Exclude<T>();

So How to loop on a list of classes and Pass them to this method e.g :

AuditManager.DefaultConfiguration.Exclude<Employee>();
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392

1 Answers1

11

Easy:

List<Type> types = new List<Type> {typeof(Employee), typeof(Department), typeof(Room)};

Or you can get type from existed object:

List<Type> types = new List<Type> {EmployeeInstance.GetType(), DepartmentInstance.GetType(), RoomInstance.GetType()};

I will try to explain difference between Employee and typeof(Employee) but better will be read this link:

Employee it's like your data contract. It have fields like X and Y.

typeof(Employee) is your type of 'contract', it have information about fields - information that contains a description about X and Y fields.


MSDN: Type