18 December, 2009
0 Comments
0 categories
If you want to delete all records from a table with LLBLGen Pro v2.6 without first fetching all records, you can use the DataAccessAdapter DeleteEntitiesDirectly function.
// Define the query that matches all records to be deleted.
// If no PredicateExpression are added all records will be deleted. RelationPredicateBucket bucket = new RelationPredicateBucket(); // If you want to delete only the customers that have an Id != 100, uncomment the following line // bucket.PredicateExpression.Add(CustomerFields.Id != 100); // Initialize DataAccessAdapter using (DataAccessAdapter da = new DataAccessAdapter("server=MyServer; database=Test; Trusted_Connection=False;")) { // Delete the records from table CustomerEntity (TSQL query: delete Customer) da.DeleteEntitiesDirectly("CustomerEntity", bucket); }
Tags: LLBLGen