- Entity Framework 6.1
I have a stored procedure that returns the following result:
So naturally those field names are not valid identifiers for the resulting POCO which I have modified to:
public class AdHoc_UspGetPassengerCountByAgeReturnDto
{
public Int32? _0_18 { get; set; }
public Int32? _19_30 { get; set; }
public Int32? _31_40 { get; set; }
public Int32? _41_50 { get; set; }
public Int32? _51_60 { get; set; }
public Int32? _61_70 { get; set; }
public Int32? _71_80 { get; set; }
public Int32? _81plus { get; set; }
}
As a result of the property name change the following:
public List<AdHoc_UspGetPassengerCountByAgeReturnDto> AdHoc_UspGetPassengerCountByAge(out int aProcResult)
{
SqlParameter procResultParam = new SqlParameter {ParameterName = "@procResult", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Output};
List<AdHoc_UspGetPassengerCountByAgeReturnDto> procResultData =
Database.SqlQuery<AdHoc_UspGetPassengerCountByAgeReturnDto>("EXEC @procResult = [AdHoc].[usp_GetPassengerCountByAge] ", procResultParam).ToList();
aProcResult = (int) procResultParam.Value;
return procResultData;
}
returns null values because the names don't match.
So what I am trying to work out is how I perform the SP call but return some generic type so that I can do the translation between what is returned to my Adhoc_UspGetPassengerCountByAgeReturnDto.
Can someone point me in the right direction please?