LinqConnect Documentation
Devart.Data.Linq Namespace / Table<TEntity> Class / DeleteOnSubmit(TEntity) Method
The entity to be deleted.
Example

In This Topic
    DeleteOnSubmit(TEntity) Method
    In This Topic
    Puts an entity from this table into a pending delete state.
    Syntax
    'Declaration
     
    Public Sub DeleteOnSubmit( _
       ByVal entity As TEntity _
    ) 
    public void DeleteOnSubmit( 
       TEntity entity
    )

    Parameters

    entity
    The entity to be deleted.
    Remarks
    The removed entity is not seen to be missing from the query results until after SubmitChanges is called. Disconnected entities must first be attached before they can be deleted. For more information, see Data Retrieval and CUD Operations in N-Tier Applications (LINQ to SQL).
    Example
    // Query the database for the rows to be deleted.
    var deleteOrderDetails =
            from details in db.OrderDetails
        where details.OrderID == 11000
    select details;
    
    foreach (var detail in deleteOrderDetails)
    {
        db.OrderDetails.DeleteOnSubmit(detail);
    }
    
    try
    {
        db.SubmitChanges();
    }
    catch (Exception e)
    {
        Console.WriteLine(e);
        // Provide for exceptions.
    }
    ' Query the database for the rows to be deleted.
    Dim deleteOrderDetails = _
            From details In db.OrderDetails() _
    Where details.OrderID = 11000 _
        Select details
    
    For Each detail As OrderDetail In deleteOrderDetails
        db.OrderDetails.DeleteOnSubmit(detail)
    Next
    
    Try
        db.SubmitChanges()
    Catch ex As Exception
        Console.WriteLine(ex)
        ' Provide for exceptions
    End Try
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also