How to discover through Reflection the base base base class from a class?

I have the following scenario:

public class BaseEntity { 
    public int Id { get; set; }
}
public class BaseAcademicEntity : BaseEntity { ... }
public class BaseFinancialEntity : BaseEntity { ... }

public class Student : BaseAcademicEntity {
    public string Name { get; set; }
    public Grade CurrentGrade { get; set; }
}
public class Grade : BaseAcademicEntity {
    public string Description { get; set; }
}

Ok, now I'll discover the properties from Student class through Reflection.

foreach (PropertyInfo property in typeof(Student).GetProperties()) {

    // Here I can discover the type of the current property.
    var type = property.PropertyType;

    // now, how to discover if this property is from BaseEntity type?
}

Like I wrote in the comment, how to discover if the property is from the BaseEntity type? Thanks!

Jon Skeet
people
quotationmark

The simplest way is to use Type.IsAssignableFrom:

if (typeof(BaseEntity).IsAssignableFrom(type))

people

See more on this question at Stackoverflow