// Generic comes to the Employee and becomes non generic. // This was discussed and found out that it's a config solution public ManagementTeam.Collection <T> ManagementGetListEntities <T>(string storedProcedure) where T : DataModel.Entities.Common.Employee, new() { var employees = new ManagementTeam.Collection <T>(); employees.Entities = new List <T>(); using (SqlConnection connection = new SqlConnection (ConfigurationManager.ConnectionStrings["SQLProviderConnectionString"].ConnectionString)) { var cmd = new SqlCommand(storedProcedure, connection); cmd.CommandType = CommandType.StoredProcedure; connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { var employee = new T(); employee.Id = Int32.Parse(reader[0].ToString()); employee.Name = reader[1].ToString(); employee.LastName = reader[2].ToString(); employees.Entities.Add(employee); //employees.Entities = (T)employees.Entities.AddToIEnumerable(employee); //employees.Entities.Add<Employee>(employee); } } return(employees); }
public Collection <T> ManagementGetEmployees <T>() where T : DataModel.Entities.Management.Employee, new() { var employees = new ManagementTeam.Collection <T>(); employees.Entities = new List <T>(); using (SqlConnection connection = new SqlConnection (ConfigurationManager.ConnectionStrings["SQLProviderConnectionString"].ConnectionString)) { var cmd = new SqlCommand("dbo.umsp_GetManagementEmployees", connection); cmd.CommandType = CommandType.StoredProcedure; connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { // select Id, Name, Surname, Team, Role, Project, Task var employee = new T(); employee.Id = Int32.Parse(reader[0].ToString()); employee.Name = reader[1].ToString(); employee.LastName = reader[2].ToString(); employee.Team = reader[3].ToString(); employee.Role = reader[4].ToString(); employee.Project = reader[5].ToString(); employee.Task = reader[6].ToString(); employees.Entities.Add(employee); //employees.Entities = (T)employees.Entities.AddToIEnumerable(employee); //employees.Entities.Add<Employee>(employee); } } return(employees); }