Table<TEntity>.InsertOnSubmit(TEntity) Table<TEntity>.InsertOnSubmit(TEntity) Table<TEntity>.InsertOnSubmit(TEntity) Table<TEntity>.InsertOnSubmit(TEntity) Method

Definición

Agrega una entidad en un estado pending insert a este Table<TEntity>.Adds an entity in a pending insert state to this Table<TEntity>.

public:
 void InsertOnSubmit(TEntity entity);
public void InsertOnSubmit (TEntity entity);
member this.InsertOnSubmit : 'Entity -> unit
Public Sub InsertOnSubmit (entity As TEntity)

Parámetros

entity
TEntity TEntity TEntity TEntity

Entidad que se va a agregar.The entity to be added.

Ejemplos

// 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

Comentarios

La entidad agregada no aparecerá en los resultados de la consulta de esta tabla hasta después de SubmitChanges se ha llamado.The added entity will not appear in query results from this table until after SubmitChanges has been called.

Se aplica a