Scott Klein
"Professional LINQ"
GetResult
())
{
listBox1.Items.Add(cp.ContactID + " " + cp.Title + " " + cp.FirstName + "
" + cp.LastName);
}
foreach (ProductsPart pp in results.GetResult())
{
listBox1.Items.Add(pp.ProductID + " " + pp.Name + " " + pp.ProductNumber);
}
}
This example also requires the System.Data.Linq.Provider namespace because it is dealing with
multiple results. It handles the contacts first, and then processes the products.
Press F5 to compile and run the project. When the form appears, click button4. The list box should be
populated with a list of contacts first, followed by a list of products. To cut down on the number of items
returned, add a WHERE clause to each SELECT statement.
You have to love the fact that LINQ can handle multiple results so easily.
Mapping and Calling User-Defined Functions
LINQ to SQL supports the mapping and calling of user-defined functions via methods defined in your
object model that represent the user-defined function. Methods are designated as functions by applying
the [Function] attribute and any associated [Parameter] attributes.
Pages:
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390