Пример #1
0
 /// <summary>
 /// 分页查询,使用Id desc排序
 /// </summary>
 /// <param name="pageIndex">页号</param>
 /// <param name="pageSize">页大小</param>
 /// <param name="recordCount">记录总数</param>
 /// <returns></returns>
 public virtual ICollection<PatientsProduct> SelectPaging(int pageIndex, int pageSize, out int recordCount)
 {
     if (Disposed)
     {
         throw new ObjectDisposedException(ToString());
     }
     recordCount = this.Count();
     int offsetCount = (pageIndex - 1) * pageSize;
     ICollection<PatientsProduct> resultList = null;
     using (var reader = SqlHelper.ExecuteReader(sqlConnection, System.Data.CommandType.Text, selectPaging,
         new SqlParameter("@PageSize", pageSize),
         new SqlParameter("@OffsetCount", offsetCount)
         ))
     {
         if (reader.HasRows)
         {
             resultList = new System.Collections.ObjectModel.Collection<PatientsProduct>();
         }
         while (reader.Read())
         {
             PatientsProduct result = new PatientsProduct();
             result.Id = reader.GetGuid(0);
             result.PatientId = reader.GetGuid(1);
             result.ProductId = reader.GetGuid(2);
             resultList.Add(result);
         }
         reader.Close();
     }
     return resultList;
 }
Пример #2
0
 /// <summary>
 /// 更新对象,使用显示事物
 /// </summary>
 /// <param name="transaction">事物对象</param>
 /// <param name="entity">一个实体对象</param>
 public virtual void Update(SqlTransaction transaction, PatientsProduct entity)
 {
     if (Disposed)
     {
         throw new ObjectDisposedException(ToString());
     }
     if (entity != null)
     {
         SqlHelper.ExecuteNonQuery(transaction, System.Data.CommandType.Text, updateById,
             new SqlParameter("@PatientId", entity.PatientId),
             new SqlParameter("@ProductId", entity.ProductId),
             new SqlParameter("@Id", entity.Id)
             );
     }
 }
Пример #3
0
        /// <summary>
        /// 查询,使用Id desc排序
        /// </summary>
        /// <param name="patientId">patientId</param>
        /// <returns></returns>
        public virtual ICollection<PatientsProduct> SelectByPatientId(Guid patientId)
        {
            if (Disposed)
            {
                throw new ObjectDisposedException(ToString());
            }

            ICollection<PatientsProduct> resultList = null;
            using (var reader = SqlHelper.ExecuteReader(sqlConnection, System.Data.CommandType.Text, selectByPatientId2,
                new SqlParameter("@PatientId", patientId)
                ))
            {

                if (reader.HasRows)
                {
                    resultList = new System.Collections.ObjectModel.Collection<PatientsProduct>();
                }
                while (reader.Read())
                {
                    PatientsProduct result = new PatientsProduct();
                    result.Id = reader.GetGuid(0);
                    result.PatientId = reader.GetGuid(1);
                    result.ProductId = reader.GetGuid(2);
                    resultList.Add(result);
                }
                reader.Close();
            }
            return resultList;
        }
Пример #4
0
 /// <summary>
 /// 创建对象
 /// </summary>
 /// <param name="entity">一个实体对象</param>
 public virtual void Insert(PatientsProduct entity)
 {
     if (Disposed)
     {
         throw new ObjectDisposedException(ToString());
     }
     if (entity != null)
     {
         SqlHelper.ExecuteNonQuery(sqlConnection, System.Data.CommandType.Text, insert,
             new SqlParameter("@Id", entity.Id),
             new SqlParameter("@PatientId", entity.PatientId),
             new SqlParameter("@ProductId", entity.ProductId)
             );
     }
 }
Пример #5
0
 /// <summary>
 /// 根据Id查询实体
 /// </summary>
 /// <param name="id">实体对象的Id</param>
 /// <returns>一个实体对象</returns>
 public virtual PatientsProduct GetById(Guid id)
 {
     if (Disposed)
     {
         throw new ObjectDisposedException(ToString());
     }
     PatientsProduct result = null;
     if (id != Guid.Empty)
     {
         using (var reader = SqlHelper.ExecuteReader(sqlConnection, System.Data.CommandType.Text, selectById,
               new SqlParameter("@Id", id)
               ))
         {
             if (reader.HasRows)
             {
                 result = new PatientsProduct();
             }
             while (reader.Read())
             {
                 result.Id = reader.GetGuid(0);
                 result.PatientId = reader.GetGuid(1);
                 result.ProductId = reader.GetGuid(2);
             }
             reader.Close();
         }
     }
     return result;
 }
Пример #6
0
 /// <summary>
 /// 删除对象,使用显示事物
 /// </summary>
 /// <param name="transaction">事物对象</param>
 /// <param name="entity">一个实体对象</param>
 public virtual void Delete(SqlTransaction transaction, PatientsProduct entity)
 {
     if (Disposed)
     {
         throw new ObjectDisposedException(ToString());
     }
     if (entity != null)
     {
         SqlTransaction tran = transaction;
         try
         {
             Delete(entity);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Dispose();
             tran = null;
         }
     }
 }
Пример #7
0
 /// <summary>
 /// 删除对象
 /// </summary>
 /// <param name="entity">一个实体对象</param>
 public virtual void Delete(PatientsProduct entity)
 {
     if (Disposed)
     {
         throw new ObjectDisposedException(ToString());
     }
     if (entity != null)
     {
         Delete(entity.Id);
     }
 }