Hello,
I am using vs2022 and C# language and oracle as backend. oracle procedure gets input as facility type and based on type it returns the list of data and each facility type have common columns with few additional columns per type. on the below code, MaptoList is an extension class method which maps the reader column and value to class. the below logic is not working and says cannot convert from non generic list to generic. please do the needful to solve the compile error.
public class Common
{
public string Name { get; set; }
public string Address { get; set; }
public string State{ get; set; }
}
public class Employee : Common
{
public string SSN{ get; set; }
}
public class Vendor : Common
{
public string TaxNumber{ get; set; }
}
public async Task<List<T>> GetFacility(string Facility_Type)
{
using (EMPDB dbConnect = new EMPDB())
{
DbCommand dbCommand = dbConnect.Database.GetDbConnection().CreateCommand();
dbCommand.CommandType = CommandType.StoredProcedure;
dbCommand.CommandText = "GetFacilityReport";
dbCommand.BuildSqlParameter("Facility_Type", OracleDbType.Varchar2, Facility_Type, ParameterDirection.Input);
List<T> lstFacility_Response= new List<T>();
if (dbCommand.Connection.State != ConnectionState.Open)
{
dbCommand.Connection.Open();
}
using (var reader = await dbCommand.ExecuteReaderAsync())
{
switch (Facility_Type)
{
case "Employee":
lstFacility_Response= reader.MapToList<Employee>();
break;
case "Vendor":
lstFacility_Response= reader.MapToList<Vendor>();
break;
}
}
}
return lstFacility_Response
}