Using LightSpeed-specific features from LINQ
Tagged as LightSpeedLightSpeed 2 includes a LINQ provider that allows you to write queries against LightSpeed using the standard LINQ syntax, such as the following:
var query = from m in UnitOfWork.Members where m.UserName == "jb" select m;
However LightSpeed offers some features that the standard LINQ syntax doesn’t support. Specifically LightSpeed allows you to control, using named aggregates, when associations or large data objects are loaded, and it supports “soft deletion” including the retrieval of soft-deleted data.
The LightSpeed LINQ provider supports named aggregates via a special WithAggregate query operator. Here’s an example of how you would force a set of Contributions (from the LightSpeed samples) to load with the ContributionDetail named aggregate:
var query = from c in UnitOfWork.Contributions where c.Title.StartsWith("A") select c; var contributions = query.WithAggregate("ContributionDetail").ToList();
This is equivalent to setting the AggregateName property on a LightSpeed Query object.
As for soft deletion, the soft delete functionality itself happens automatically at the LightSpeed engine level. The only extension is a way to include soft-deleted items in the LINQ query. This is done using the IncludeDeleted query operator:
var query = from a in UnitOfWork.Accounts select a; var accounts = query.IncludeDeleted().ToList();
This is equivalent to setting the IncludeDeleted property on a LightSpeed Query object.
By using these two custom operators you can continue to access these LightSpeed features from within LINQ.
Leave a Reply
![]()
BrainDump (1)
Community Code (1)
Events (6)
General (31)
Lab Samples (2)
LightSpeed (132)
MegaPack (3)
News (48)
Products (64)
Projects (4)
Screencast (6)
SharePoint (1)
Silverlight (5)
Silverlight Elements (12)
SimpleDB Management Tools (11)
Visual Studio (4)
VS File Explorer (5)
WPF (31)
WPF Diagramming (14)
WPF Elements (22)
WPF Property Grid (24)
![]()
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007





Posted by Ivan Towlson on 11 June 2008


