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

In This Topic
    InsertOnSubmit(TEntity) Method
    In This Topic
    Adds an entity in a pending insert state to this Table(TEntity).
    Syntax
    'Declaration
     
    Public Sub InsertOnSubmit( _
       ByVal entity As TEntity _
    ) 
    public void InsertOnSubmit( 
       TEntity entity
    )

    Parameters

    entity
    The entity to be added.
    Remarks
    The added entity will not be observed in query results from this table until after SubmitChanges has been called.
    Example
    // Create a new Order object.
    Order ord = new Order
    {
        OrderID = 12000,
        ShipCity = "Seattle",
        OrderDate = DateTime.Now
        // …
    };
    
    // Add the new object to the Orders collection.
    db.Orders.InsertOnSubmit(ord);
    
    // Submit the change to the database.
    try
    {
        db.SubmitChanges();
    }
    catch (Exception e)
    {
        Console.WriteLine(e);
        // Make some adjustments.
        // ...
        // Try again.
        db.SubmitChanges();
    }
    ' Create a new Order object.
    Dim ord As New Order With _
    {.OrderID = 12000, _
    .ShipCity = "Seattle", _
    .OrderDate = DateTime.Now}
    
    ' Add the new object to the Orders collection.
    db.Orders.InsertOnSubmit(ord)
    
    ' Submit the change to the database.
    Try
        db.SubmitChanges()
    Catch e As Exception
        Console.WriteLine(e)
        ' Make some adjustments.
        ' ...
        ' Try again.
        db.SubmitChanges()
    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