Bltfast

Hello again,

using Linq to Sql May 2006 CTP and the Including method I can pre load queries' results avoiding to call the DB repeately. In Orcas March 2007 it seems that the Including method has been removed. Is there either another method or way to obtain the same result

Thank you in advance.




Re: LINQ Project General Where is the Including method in Orcas March 2007?

jwooley

You can use the .ToArray method to prefetch the results with the March drop. It appears as you indicated that .Including is not .Included at this time.

Jim Wooley
http://devauthority.com/blogs/jwooley






Re: LINQ Project General Where is the Including method in Orcas March 2007?

Matt Warren - MSFT

You can use the new DataShape object to assign include/load-with behaviors to the DataContext.

DataShape s = new DataShape();
s.LoadWith<Customer>(c => c.Orders);

DataContext dc = ...;
dc.Shape = s;

var q = from c in dc.Customers where xxx select c;






Re: LINQ Project General Where is the Including method in Orcas March 2007?

Joe Albahari

Including has been replaced with DataShape - refer to this thread:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1259916&SiteID=1

Here's a complete example:

var data = new MyDataContext ();

data.Log = Console.Out;

DataShape shape = new DataShape ();
shape.LoadWith<Customer> (c => c.Purchases);
shape.AssociateWith<Customer> (c => c.Purchases.Where (p => p.Price > 1000));
data.Shape = shape;

foreach (Customer c in data.Customers)
{
Console.WriteLine (c.Name);
foreach (Purchase p in c.Purchases) // No extra round-trip
Console.WriteLine (" " + p.Price);
}






Re: LINQ Project General Where is the Including method in Orcas March 2007?