Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 InsertOnSubmit Method
.NET Framework Class Library
Table<(Of <(TEntity>)>)..::.InsertOnSubmit Method

Updated: November 2007

Adds an entity in a pending insert state to this Table<(Of <(TEntity>)>).

Namespace:  System.Data.Linq
Assembly:  System.Data.Linq (in System.Data.Linq.dll)

Visual Basic (Declaration)
Public Sub InsertOnSubmit ( _
    entity As TEntity _
)
Visual Basic (Usage)
Dim instance As Table
Dim entity As TEntity

instance.InsertOnSubmit(entity)
C#
public void InsertOnSubmit(
    TEntity entity
)
Visual C++
public:
void InsertOnSubmit(
    TEntity entity
)
J#
public void InsertOnSubmit(
    TEntity entity
)
JScript
public function InsertOnSubmit(
    entity : TEntity
)

Parameters

entity
Type: TEntity

The entity to be added.

The added entity will not be observed in query results from this table until after SubmitChanges has been called.

Visual Basic
' 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

C#
// 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();
}

Windows Vista, Windows XP SP2, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker