public List <AnimalSim> GetAnimals(int CompanyId, int SexId) { List <AnimalSim> ReturnObject = new List <AnimalSim>(); AnimalSim ins; DataBaseConnection dbConn = new DataBaseConnection(); using (var con = dbConn.SqlConn()) { con.Open(); using (SqlCommand cmd = new SqlCommand("exec " + CommonStrings.SimAnimals + " @CompanyId, @SexId", con)) { cmd.Parameters.AddWithValue("@CompanyId", CompanyId); cmd.Parameters.AddWithValue("@SexId", SexId); using (var drI = cmd.ExecuteReader()) { while (drI.Read()) { ins = new AnimalSim(); ins.AnimalId = Convert.ToInt32(drI["AnimalId"]); ins.DeviceAddress = drI["DeviceAddress"].ToString(); ReturnObject.Add(ins); } } } } return(ReturnObject); }
public List<AnimalSim> GetAnimals(int CompanyId, int SexId) { List<AnimalSim> ReturnObject = new List<AnimalSim>(); AnimalSim ins; DataBaseConnection dbConn = new DataBaseConnection(); using (var con = dbConn.SqlConn()) { con.Open(); using (SqlCommand cmd = new SqlCommand("exec " + CommonStrings.SimAnimals + " @CompanyId, @SexId", con)) { cmd.Parameters.AddWithValue("@CompanyId", CompanyId); cmd.Parameters.AddWithValue("@SexId", SexId); using (var drI = cmd.ExecuteReader()) { while (drI.Read()) { ins = new AnimalSim(); ins.AnimalId = Convert.ToInt32(drI["AnimalId"]); ins.DeviceAddress = drI["DeviceAddress"].ToString(); ReturnObject.Add(ins); } } } } return ReturnObject; }