Deletes entities by executing SQL directly against the database. NB. No entities are materialized and therefore no callbacks run, entities are not removed from the second-level cache or full-text search index etc.

Namespace:  Mindscape.LightSpeed
Assembly:  Mindscape.LightSpeed (in Mindscape.LightSpeed.dll)
Version: 4.0.0.0 (4.0.0.0)

Syntax

C#
void Remove(
	Query query
)
Visual Basic (Declaration)
Sub Remove ( _
	query As Query _
)

Parameters

query
Type: Mindscape.LightSpeed.Querying..::.Query
A query used to determine the entities to delete.

Examples

CopyC#
// Delete all user accounts which have been inactive for more than 180 days
DateTime expiryDate = DateTime.UtcNow.AddDays(-180);
Query query = new Query(typeof(UserAccount), Entity.Attribute("LastActive") < expiryDate);
unitOfWork.Remove(query);
unitOfWork.SaveChanges();

See Also