ndependcqlinq

Get the IType from a known type


I need to check if the types that have the name terminating with "Repository" derives from a base class called "DefaultRepositoryBase".

I've searched but I' ve not been able to find how to get the IType from a known type...how can I achieve this and then pass it to the t.DerivesFrom(itype)

from  t in Application.Types
where t.NameLike("Repository")
select t

Solution

  • You can write

    t.DerivesFrom("Namespace.TypeName")
    

    or you can write something like

    let baseType = Application.Types.WithFullName("Namespace.TypeName").Single()
    ...
    t.DerivesFrom(baseType)