Ejemplo n.º 1
0
        public CategoryDAL FindCategoryByID(int CategoryID)
        {
            CategoryDAL rv = null;

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("FindCategoryByID", Con))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@CategoryID", CategoryID);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        CategoryMapper mapper = new CategoryMapper(reader);
                        if (reader.Read())
                        {
                            rv = mapper.ToCategory(reader);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log(ex);
                throw;
            }
            return(rv);
        }
Ejemplo n.º 2
0
        public List <CategoryDAL> GetCategories(int skip, int take)
        {
            List <CategoryDAL> rv = new List <CategoryDAL>();

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("GetCategories", Con))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@skip", skip);
                    command.Parameters.AddWithValue("@take", take);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        CategoryMapper mapper = new CategoryMapper(reader);
                        while (reader.Read())
                        {
                            CategoryDAL c = mapper.ToCategory(reader);
                            rv.Add(c);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log(ex);
                throw;
            }
            return(rv);
        }
Ejemplo n.º 3
0
        public CategoryDAL ToCategory(SqlDataReader r)
        {  //different from ctor used many times in loops
            CategoryDAL rv = new CategoryDAL();

            rv.CategoryID = GetInt32OrZero(r, CategoryIDOrdinal);
            rv.Category   = GetStringOrNull(r, CategoryOrdinal);

            return(rv);
        }
Ejemplo n.º 4
0
        public CategoryDAL ToCategory(SqlDataReader r)
        {
            CategoryDAL rv = new CategoryDAL();

            rv.CategoryID = GetInt32OrZero(r, CategoryIDOrdinal);
            rv.Category   = GetStringOrNull(r, CategoryOrdinal);

            return(rv);
        }