コード例 #1
0
        public List <ObservationsDAL> GetObservationsRelatedToObs(int skip, int take)
        {
            List <ObservationsDAL> ProposedReturnValue = new List <ObservationsDAL>();

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("GetObservationsRelatedToObs", _connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;

                    command.Parameters.AddWithValue("@Skip", skip);
                    command.Parameters.AddWithValue("@Take", take);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        ObservationsMapper m = new ObservationsMapper(reader);
                        while (reader.Read())
                        {
                            ObservationsDAL r = m.ObservationFromReader(reader);
                            ProposedReturnValue.Add(r);
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
            }
            return(ProposedReturnValue);
        }
コード例 #2
0
        public ObservationsDAL FindObservation(int ObsID)
        {
            ObservationsDAL ProposedReturnValue = null;

            try
            {
                EnsureConnected();
                using (SqlCommand command
                           = new SqlCommand("FindObservation", _connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@ObsID", ObsID);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        ObservationsMapper m = new ObservationsMapper(reader);
                        int count            = 0;
                        while (reader.Read())
                        {
                            ProposedReturnValue = m.ObservationFromReader(reader);
                            count++;
                        }
                        if (count > 1)
                        {
                            throw new
                                  Exception($"Found more than 1 Observation with key {ObsID}");
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
            }
            return(ProposedReturnValue);
        }