Let's say I have The class
public partial class MyEntities: DbContext { public DbSet<Customer> Customers {get;set;} public DbSet<CustomerInfo> CustomerInfos {get;set;} public DbSet<Order> Orders {get;set;} // etc } How can I find the property that has the generic type Customer?
In other words I am looking to create the method:
public PropertyInfo GetProperty<T>(){ var allProperties = TypeOf(MyEntities).GetProperties(); // implementation } If I call the method as GetProperty<Customer>() then I will like to get the first property. If I call the method as GetProperty<Order>() then I will like to get the last property. How can I examine the <Type> with reflection?