コード例 #1
0
        public static IList <HospitalProductEntity> GetByUnit(string unitId)
        {
            var sql = string.Format(@"SELECT {0} FROM hospital_products WHERE unit_id = @p_unit_id", COLUMN_SQL);

            var db = DatabaseFactory.CreateDatabase();

            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_unit_id", DbType.String, unitId);

            var list = new List <HospitalProductEntity>();

            using (var reader = db.ExecuteReader(dc))
            {
                while (reader.Read())
                {
                    var product = new HospitalProductEntity();
                    product.Init(reader);

                    list.Add(product);
                }
            }

            return(list);
        }
コード例 #2
0
        internal static HospitalProductEntity GetOneProduct(string productId, string hospitalId)
        {
            var sql = string.Format(@"SELECT top 1 {0} FROM hospital_products 
WHERE hospital_id = @p_hospital_id and product_id = @p_product_id", COLUMN_SQL);

            var db = DatabaseFactory.CreateDatabase();

            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_hospital_id", DbType.String, hospitalId);
            db.AddInParameter(dc, "p_product_id", DbType.String, productId);

            HospitalProductEntity entity = null;

            using (var reader = db.ExecuteReader(dc))
            {
                while (reader.Read())
                {
                    entity = new HospitalProductEntity();
                    entity.Init(reader);

                    break;
                }
            }

            return(entity);
        }