I have a Linq to SQL DataContext with SQL functions into it. While the retrieve object is good, I would like to add a property to the object and same time shortens the object name. So I made an object Reminder that inherits from the Linq to SQL object fnRTHU_ReminderByTaskResult with the property I wanted.
public class Reminder : fnRTHU_ReminderByTaskResult
{
public string MyProperty {get;set;}
}
Then when the function is bind to the list I try in the aspx file to do:
<asp:Literal runat="server" Text='<%# ((Reminder)DataBinder.Container).MyProperty %>' />
Where DataBinder.Container is of type fnRTHU_ReminderByTaskResult. This results in an InvalidCastException, unable to cast object type fnRTHU_ReminderByTaskResult to type Reminder. I don't understand since I inherit from the type I'm casting from.