This project is read-only.

Restriction Operators :: Where - Simple 2

This sample prints a list of all products that are out of stock. It selects each item from the product list where the number of units in stock equals zero.

function linq2()
    List products = GetProductList();
    $products = getProductList();

    $soldOutProducts = from('$p')->in($products)->where('$p->UnitsInStock == 0')->select('$p');

    echo 'Sold out products:<br />';

    foreach ($soldOutProducts as $product)
        echo $product->ProductName.' is sold out!';


Sold out products:
Chef Anton's Gumbo Mix is sold out!
Alice Mutton is sold out!
Thüringer Rostbratwurst is sold out!
Gorgonzola Telino is sold out!
Perth Pasties is sold out!

Last edited Nov 1, 2008 at 9:57 PM by vojtechzicha, version 1


No comments yet.