data filter using dataloadoptions

Posted by Tassadaque on Stack Overflow See other posts from Stack Overflow or by Tassadaque
Published on 2010-05-27T17:40:02Z Indexed on 2010/05/27 17:41 UTC
Read the original article Hit count: 211

Filed under:
|

Using dataloadoptions i have tried the following example

    Northwnd db = new Northwnd(@"northwnd.mdf");
// Preload Orders for Customer.
// One directive per relationship to be preloaded.
DataLoadOptions ds = new DataLoadOptions();
ds.LoadWith<Customer>(c => c.Orders);
ds.AssociateWith<Customer>
    (c => c.Orders.Where(p => p.ShippedDate != DateTime.Today));
db.LoadOptions = ds;

var custQuery =
    from cust in db.Customers
    where cust.City == "London"
    select cust;

foreach (Customer custObj in custQuery)
{
    Console.WriteLine("Customer ID: {0}", custObj.CustomerID);
    foreach (Order ord in custObj.Orders)
    {
        Console.WriteLine("\tOrder ID: {0}", ord.OrderID);
        foreach (OrderDetail detail in ord.OrderDetails)
        {
            Console.WriteLine("\t\tProduct ID: {0}", detail.ProductID);
        }
    }
}

Now i need to ask how can i display Category ID and Category Name of the productID (i am supposing that One product can be in at most one category) by extending the above example Regards

© Stack Overflow or respective owner

Related posts about c#

Related posts about linq-to-sql