We've ran into a scenario where we need to be able to return the name of an entity type as a value in the result of an esql statement.
The problem is this, we have a generic helper in place that builds and runs an esql statement to return a result that's passed into a SelectList on an MVC3 application.
The text column is an expression taken from an attribute added to a property on the model.
So for example if we wanted the dropdown to list a persons name as Last, First we add an attribute with an expression like: 'it.[LastName] + ", " + it.[FirstName]' Which produces a statement like this:
SELECT it.[Id] AS Id, it.[LastName] + ", " + it.[FirstName] AS Name
FROM OfType([AuditedObject], [User]) AS it
We've run into a scenario involving an abstract type in EF4.3 using TPT. We need to enumerate the derived entities using this helper method. The method enumerates and returns all the derived entities fine when we just want basic data like this:
SELECT it.[Id] AS Id, it.[Name] AS Name
FROM OfType([AuditedObject], [DatumObject]) AS it
But we need a way to indicate what type each entity is. Something like this pseudo code:
SELECT it.[Id] AS Id, it.GetType().Name + " - " + it.[Name] AS Name
FROM OfType([AuditedObject], [DatumObject]) AS it
Does anyone have any knowledge of how I might accomplish this?