Uredi

Deli z drugimi prek


Table<TEntity>.DeleteAllOnSubmit<TSubEntity> Method

Definition

Puts all entities from the collection into a pending delete state.

public:
generic <typename TSubEntity>
 where TSubEntity : TEntity void DeleteAllOnSubmit(System::Collections::Generic::IEnumerable<TSubEntity> ^ entities);
public void DeleteAllOnSubmit<TSubEntity> (System.Collections.Generic.IEnumerable<TSubEntity> entities) where TSubEntity : TEntity;
member this.DeleteAllOnSubmit : seq<#'Entity> -> unit
Public Sub DeleteAllOnSubmit(Of TSubEntity As TEntity) (entities As IEnumerable(Of TSubEntity))

Type Parameters

TSubEntity

The type of the elements to delete.

Parameters

entities
IEnumerable<TSubEntity>

The entities to delete.

Examples

The following example shows one use for this method:

IEnumerable<Customer> customersWithoutOrders = (from c in db.Customers  
   where c.Orders.Count == 0  
   select c).ToList();  

db.Customers.DeleteAllOnSubmit(customersWithoutOrders);  
db.SubmitChanges();  
Dim customersWithoutOrders As IEnumerable(Of Customer) = (From c In db.Customers _   
    Where c.Orders.Count = 0 _   
    Select c).ToList()  

db.Customers.DeleteAllOnSubmit(customersWithoutOrders)  
db.SubmitChanges()  

Remarks

Entities that are put into the pending delete state with this method do not disappear from query results until after SubmitChanges is called. Disconnected entities must be attached before they can be deleted. For more information, see Data Retrieval and CUD Operations in N-Tier Applications (LINQ to SQL).

Applies to