DataLoadOptions replaces DataShape by ThinqLinq

DataLoadOptions replaces DataShape

As I continue updating my projects to Visual Studio 2008 Beta 2, I found yet another namespace change. This time, it's not the namespace, but object name that has changed.

With Beta 1, we could specify what objects would be loaded automatically with their parents using the DataShape object that you attach to the DataContext. Here is a bit of code that would load a set of books whenever the associated subject was loaded. This would have the benefit of not lazy loading each child collection and reduces the number of requests between the application and database. Here is the code we used with Beta 1:

DataShape shape = new DataShape();
shape.LoadWith<Subject>(subject => subject.Books);
dataContext.Shape = shape;

With Beta 2, the shape is changed to DataLoadOptions. Thus the above code can be easily re-written as follows:

DataLoadOptions options = new DataLoadOptions();
options.LoadWith<Subject>(Subject => Subject.Books);
dataContext.LoadOptions = options;

Matt Warren discusses the change a bit in the following Linq Forum thread: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1678307&SiteID=1. Personally, I prefer the new name as it disambiguates it from the MSDataShape used with data cubes.

On a related note, if you haven't checked out Matt's blog, it is a definite must read for anyone interested in LINQ to SQL.

Posted on - Comment
Categories: LINQ) -
comments powered by Disqus