public static void Main()
bool myClass = InheritsBaseEntity(typeof(MyClass));
bool myOtherClass = InheritsBaseEntity(typeof(MyOtherClass));
bool audit = InheritsBaseEntity(typeof(Audit));
Console.WriteLine(nameof(myClass) + " " + myClass);
Console.WriteLine(nameof(myOtherClass) + " " + myOtherClass);
Console.WriteLine(nameof(audit) + " " + audit);
private static bool InheritsBaseEntity(Type type)
while (type != null && type != typeof(object))
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(BaseEntity<>))
public abstract class BaseEntity<TId>
public TId Id { get; set; }
public class MyClass : BaseEntity<Guid>{}
public class MyOtherClass : BaseEntity<int>{}
public class Audit : BaseEntity<object>{}