コード例 #1
0
ファイル: ProductSPManager.cs プロジェクト: sajmaxx/CodeShip
        public virtual List <Product> Search(ProductSearch search)
        {
            // Create SQL to call a stored procedure
            SQL = "SalesLT.Product_Search";

            // Create parameters for searching
            var parameters = new List <IDbDataParameter> {
                // Add parameters for CommandObject
                CreateParameter("Name", (object)search.Name ?? DBNull.Value, true),
                CreateParameter("ProductNumber", (object)search.ProductNumber ?? DBNull.Value, true),
                CreateParameter("BeginningCost", (object)search.BeginningCost ?? DBNull.Value, true),
                CreateParameter("EndingCost", (object)search.EndingCost ?? DBNull.Value, true)
            };

            // Submit SQL to search for rows
            return(GetRecords <Product>(SQL, CommandType.StoredProcedure, parameters.ToArray()));
        }
コード例 #2
0
        public override List <Product> Search(ProductSearch search)
        {
            // Create SQL to search for rows
            SQL  = "SELECT [ProductID],[Name],[ProductNumber],[Color],[StandardCost],[ListPrice],[Size],[Weight],[ProductCategoryID],[ProductModelID],[SellStartDate],[SellEndDate],[DiscontinuedDate],[ModifiedDate] FROM SalesLT.Product";
            SQL += " WHERE (@Name          IS NULL OR NAME          LIKE @Name + '%')";
            SQL += " AND   (@ProductNumber IS NULL OR ProductNumber LIKE @ProductNumber + '%')";
            SQL += " AND   (@BeginningCost IS NULL OR StandardCost  >=   @BeginningCost)";
            SQL += " AND   (@EndingCost    IS NULL OR StandardCost  <=   @EndingCost)";

            // Create parameters for searching
            var parameters = new List <IDbDataParameter> {
                // Add parameters for CommandObject
                CreateParameter("Name", (object)search.Name ?? DBNull.Value, true),
                CreateParameter("ProductNumber", (object)search.ProductNumber ?? DBNull.Value, true),
                CreateParameter("BeginningCost", (object)search.BeginningCost ?? DBNull.Value, true),
                CreateParameter("EndingCost", (object)search.EndingCost ?? DBNull.Value, true)
            };

            // Submit SQL to search for rows
            return(GetRecordsUsingDataSet <Product>(SQL, parameters.ToArray()));
        }
コード例 #3
0
        public virtual int Count(ProductSearch search)
        {
            // Create SQL to count rows
            SQL  = "SELECT Count(*) FROM SalesLT.Product";
            SQL += " WHERE (@Name          IS NULL OR NAME          LIKE @Name + '%')";
            SQL += " AND   (@ProductNumber IS NULL OR ProductNumber LIKE @ProductNumber + '%')";
            SQL += " AND   (@BeginningCost IS NULL OR StandardCost  >=   @BeginningCost)";
            SQL += " AND   (@EndingCost    IS NULL OR StandardCost  <=   @EndingCost)";

            // Create parameters for counting
            var parameters = new List <IDbDataParameter> {
                // Add parameters for CommandObject
                CreateParameter("Name", (object)search.Name ?? DBNull.Value, true),
                CreateParameter("ProductNumber", (object)search.ProductNumber ?? DBNull.Value, true),
                CreateParameter("BeginningCost", (object)search.BeginningCost ?? DBNull.Value, true),
                CreateParameter("EndingCost", (object)search.EndingCost ?? DBNull.Value, true)
            };

            // Submit SQL to count records
            return(CountRecords(SQL, parameters.ToArray()));
        }