When using TPH I have different types inheriting from a base. We have a search that queries across the abstract type. In the results, we want to show the type:
ie. abstract Vehicle
Car: Vehicle Truck: Vehicle
in the results, I want to show 'type' - ie. 'Car' and 'Truck'.
I attempted to use GetType().Name but this fails.
Here is sample:
IQueryable<CompanySearchResult> q = from company in _ctx.Companies
select new CompanySearchResult
{
CompanyName = company.CompanyName,
CompanyId = company.Id,
Type = company.GetType().Name
};