コード例 #1
0
        private static List <IQueryPart> GetQuerypartsProduct(ProductQueryParams param)
        {
            var querieParts = new List <IQueryPart>();

            FillProductQuerie(querieParts, param);
            return(querieParts);
        }
コード例 #2
0
        /// <summary>
        /// Returns a list of products by the given searchData
        /// </summary>
        /// <param name="productQueryParams">The seachdata</param>
        /// <param name="db">the database</param>
        /// <returns></returns>
        public static List <Product> FindMatchingProduct(ProductQueryParams productQueryParams, IDatabase db)
        {
            List <IQueryPart> querieParts = GetQuerypartsProduct(productQueryParams);

            string queryText;

            if (querieParts.Count() == 0)
            {
                queryText = "SELECT product_id FROM Products";
            }
            else
            {
                queryText = QueryCreation.CreateQueryText(querieParts);
            }
            string CommandGetNotebooks = string.Format("SELECT * FROM " +
                                                       "  ( {0} ) AS PID " +
                                                       " INNER JOIN Products As p ON p.product_id = PID.product_id", queryText);

            using (var getNotebook = db.CreateQueryCommand(CommandGetNotebooks))
            {
                QueryCreation.SetQueryParameters(getNotebook, querieParts);
                using (IReader reader = getNotebook.ExecuteReader())
                {
                    return(ProductReader.ReadForProducts(reader));
                }
            }
        }
コード例 #3
0
 private static void FillProductQuerie(List <IQueryPart> queryParts, ProductQueryParams param)
 {
     if (param.Name != null)
     {
         queryParts.Add(GetProductsByName(param.Name));
     }
     if (param.Price != null)
     {
         queryParts.Add(GetProductsByPriceQuery(param.Price));
     }
 }
コード例 #4
0
        /// <summary>
        /// Searches for the Products in the Database
        /// </summary>
        /// <param name="param"></param>
        /// <returns>Returns a list of Products</returns>
        public List <Product> FindMatchingProducts(ProductQueryParams param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }

            if (param is NotebookQueryParams notebookParams)
            {
                return(NotebookSearchQueries.FindMatchingNotebooks(notebookParams, _db));
            }
            else
            {
                return(ProductSearchQueries.FindMatchingProduct(param, _db));
            }
        }
コード例 #5
0
 private static void FillQueryPartsWithNotebookProductQuery(List <IQueryPart> queryParts, ProductQueryParams param)
 {
     if (param.Price != null)
     {
         queryParts.Add(GetNotebooksByPriceQuery(param.Price));
     }
     if (param.Name != null)
     {
         queryParts.Add(GetNotebooksByName(param.Name));
     }
 }