I have a problem with the return type of the method.
The method returns a linq object, which currently returns the type tblAppointment. This method is shown below:
public tblAppointment GetAppointment(int id)
{
var singleAppointment = (from a in dc.tblAppointments
where a.appID == id
select a).SingleOrDefault();
return singleAppointment;
}
The problem is that tblAppointment is abstract and has many subtypes that inherit it. When I try to return an object that is of type "destinationTypeA" and calls the .GetType () method, it gives me the correct subtype, but when I try to access the properties, it allows me to access the parent properties, If I take the object and pass it to a new subtype object, then it works and allows me to access everything I need, but it seems messy.
var viewSingleAppointment = appointmentRepos.GetAppointment(appointmentId);
Debug.Write(viewSingleAppointment.GetType()); //returns type i want
if (viewSingleAppointment is tblSingleBirthAppointment)
{
tblSingleBirthAppointment myApp = (tblSingleBirthAppointment)viewSingleAppointment; //need to do this to access TypeA properties for some reason
}
: , select ( 20) , , , , .