public SimuuDAL Simuu_FindBySimuuID(int simuuID) { SimuuDAL ProposedReturnValue = null; try { EnsureConnected(); using (SqlCommand command = new SqlCommand("Simuu_FindBySimuuID", _connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@SimuuID", simuuID); using (SqlDataReader reader = command.ExecuteReader()) { SimuuMapper mapper = new SimuuMapper(reader); int count = 0; while (reader.Read()) { ProposedReturnValue = mapper.SimuuFromReader(reader); count++; } if (count > 1) { throw new Exception($"Found more than 1 Simuu with key {simuuID}"); } } } } catch (Exception ex) when(Log(ex)) { // No access to scope - Exception thrown before entering } return(ProposedReturnValue); }
public List <SimuuDAL> Simuus_GetRelatedToUserID(int userID, int skip, int take) { List <SimuuDAL> proposedReturnValue = new List <SimuuDAL>(); try { EnsureConnected(); using (SqlCommand command = new SqlCommand("Simuus_GetRelatedToUserID", _connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@UserID", userID); command.Parameters.AddWithValue("@Skip", skip); command.Parameters.AddWithValue("@Take", take); using (SqlDataReader reader = command.ExecuteReader()) { SimuuMapper mapper = new SimuuMapper(reader); while (reader.Read()) { SimuuDAL reading = mapper.SimuuFromReader(reader); proposedReturnValue.Add(reading); } } } } catch (Exception ex) when(Log(ex)) { // No access to scope - Exception thrown before entering } return(proposedReturnValue); }