示例#1
0
        /// <summary>
        /// Delete by primary key
        /// </summary>
        /// <param name="keys">primary keys</param>
        /// <returns>true for successfully deleted</returns>
        public bool Delete(CRecep_sample_detail_elemKeys keys)
        {
            NpgsqlCommand sqlCommand = new NpgsqlCommand();

            sqlCommand.CommandText = "public.sp_recep_sample_detail_elem_DeleteByPrimaryKey";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                sqlCommand.Parameters.Add(new NpgsqlParameter("p_idrecep_sample_detail_elem", NpgsqlDbType.Bigint, 8, "", ParameterDirection.Input, false, 0, 0, DataRowVersion.Proposed, keys.Idrecep_sample_detail_elem));


                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception("CRecep_sample_detail_elem::DeleteByKey::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }
示例#2
0
        /// <summary>
        /// Select by primary key
        /// </summary>
        /// <param name="keys">primary keys</param>
        /// <returns>CRecep_sample_detail_elem business object</returns>
        public CRecep_sample_detail_elem SelectByPrimaryKey(CRecep_sample_detail_elemKeys keys)
        {
            NpgsqlCommand sqlCommand = new NpgsqlCommand();

            sqlCommand.CommandText = "public.sp_recep_sample_detail_elem_SelectByPrimaryKey";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                sqlCommand.Parameters.Add(new NpgsqlParameter("p_idrecep_sample_detail_elem", NpgsqlDbType.Bigint, 8, "", ParameterDirection.Input, false, 0, 0, DataRowVersion.Proposed, keys.Idrecep_sample_detail_elem));


                MainConnection.Open();

                NpgsqlDataReader dataReader = sqlCommand.ExecuteReader();

                if (dataReader.Read())
                {
                    CRecep_sample_detail_elem businessObject = new CRecep_sample_detail_elem();

                    PopulateBusinessObjectFromReader(businessObject, dataReader);

                    return(businessObject);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("CRecep_sample_detail_elem::SelectByPrimaryKey::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }