This property is called DeferredLoadingEnabled and is used as shown here:
AdventureWorks db = new AdventureWorks("Integrated Security=sspi");
db.DeferredLoadingEnabled = false;
254
Chapter 12: Advanced Query Concepts
Keep in mind that deferred loading is automatically turned off when object tracking (the ObjectTrackingEnabled
property of the DataContext) is turned off. Object tracking is discussed later in this chapter.
You might consider using this property when you want to return only a portion of the query and do
something with those results, such as sending the partial results to a web service.
Composite Keys
Occasionally, you need more than one attribute to uniquely identify an entity. That??™s where composite
keys come in; they enable you to include multiple columns in a query when the operator accepts only a
single argument. In those cases, your best bet is to create an anonymous type that represents the combination
of the multiple columns you need to pass.
The LINQ group operator (GroupBy in Visual Basic), for instance, takes a single argument, but you can
see in the following example that an anonymous type is created and used to pass in two columns instead
of the one:
AdventureWorks db = new AdventureWorks("Integrated Security=sspi");
var conQuery =
from con in db.
Pages:
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411