Ejemplo n.º 1
0
        public static ProductKitComponentCollection LoadForKitComponent(Int32 kitComponentId)
        {
            ProductKitComponentCollection ProductKitComponents = new ProductKitComponentCollection();
            //CREATE THE DYNAMIC SQL TO LOAD OBJECT!
            StringBuilder selectQuery = new StringBuilder();

            selectQuery.Append("SELECT " + ProductKitComponent.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_ProductKitComponents");
            selectQuery.Append(" WHERE KitComponentId = @kitComponentId");
            selectQuery.Append(" ORDER BY OrderBy");
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());

            database.AddInParameter(selectCommand, "@kitComponentId", System.Data.DbType.Int32, kitComponentId);
            //EXECUTE THE COMMAND
            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read())
                {
                    ProductKitComponent productKitComponent = new ProductKitComponent();
                    ProductKitComponent.LoadDataReader(productKitComponent, dr);
                    ProductKitComponents.Add(productKitComponent);
                }
                dr.Close();
            }
            return(ProductKitComponents);
        }