public int InsertCategoriesGen(CategoriesGen categoriesGen)
        {
            var returnobj = baseDao.Insert(categoriesGen);

            if (returnobj != null)
            {
                return(Convert.ToInt32(returnobj));
            }
            return(0);
        }
示例#2
0
        /// <summary>
        /// WriteTest
        /// </summary>
        /// <param name="repeatTime"></param>
        /// <returns></returns>
        public long WriteTest(int repeatTime)
        {
            return(Utility.PerformanceWatch(
                       () =>
            {
                for (int i = 0; i < repeatTime; i++)
                {
                    var customer = new CustomersGen
                    {
                        CompanyName = "Newcvompanyname",
                        ContactName = "ccc",
                        Address = "asdcadsdws",
                        ContactTitle = "adsdf",
                        City = "ku2na",
                        Country = "chi2na",
                        Phone = "231",
                        PostalCode = "234",
                        Region = "ASIA",
                        CustomerID = "9011"
                    };

                    int customerIdFromDb = customersGenDao.InsertCustomersGen(customer);

                    var catagore = new CategoriesGen()
                    {
                        CategoryName = "xdf", Description = "asfb"
                    };
                    int categoryIDfromDb = categoriesGenDao.InsertCategoriesGen(
                        catagore
                        );

                    var product = new ProductsGen
                    {
                        ProductName = "Blue Widget234",
                        UnitPrice = 35.56M,
                        CategoryID = categoryIDfromDb
                    };

                    //Insert
                    product.ProductID = productsGenDao.InsertProductsGen(product
                                                                         );

                    product.ProductName = "ProductNameChange";
                    //Update
                    productsGenDao.UpdateProductsGen(product);

                    //Delete
                    productsGenDao.DeleteProductsGen(product);
                    customersGenDao.DeleteCustomersGen(customer);
                    categoriesGenDao.DeleteCategoriesGen(catagore);
                }
            }));
        }
        /// <summary>
        /// 删除CategoriesGen
        /// </summary>
        /// <param name="categoriesGen">CategoriesGen实体对象</param>
        /// <returns>状态代码</returns>
        public int DeleteCategoriesGen(CategoriesGen categoriesGen)
        {
            try
            {
                Object result  = baseDao.Delete <CategoriesGen>(categoriesGen);
                int    iReturn = Convert.ToInt32(result);

                return(iReturn);
            }
            catch (Exception ex)
            {
                throw new DalException("调用CategoriesGen时,访问Delete时出错", ex);
            }
        }
        /// <summary>
        ///  检索CategoriesGen,带翻页
        /// </summary>
        /// <param name="obj">CategoriesGen实体对象检索条件</param>
        /// <param name="pagesize">每页记录数</param>
        /// <param name="pageNo">页码</param>
        /// <returns>检索结果</returns>
        public IList <CategoriesGen> GetListByPage(CategoriesGen obj, int pagesize, int pageNo)
        {
            try
            {
                StringBuilder sbSql = new StringBuilder(200);

                sbSql.Append(@"select CategoryID, CategoryName, Description, Picture from Categories (nolock) ");
                sbSql.Append(" order by CategoryID desc ");
                sbSql.Append(string.Format("OFFSET {0} ROWS FETCH NEXT {1} ROWS ONLY", (pageNo - 1) * pagesize, pagesize));
                IList <CategoriesGen> list = baseDao.SelectList <CategoriesGen>(sbSql.ToString());
                return(list);
            }
            catch (Exception ex)
            {
                throw new DalException("调用CategoriesGenDao时,访问GetListByPage时出错", ex);
            }
        }