다음을 통해 공유


Table<TEntity>.InsertOnSubmit(TEntity) 메서드

정의

Table<TEntity>에 엔터티를 pending insert 상태로 추가합니다.

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

매개 변수

entity
TEntity

추가할 엔터티입니다.

구현

예제

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

설명

추가된 엔터티는 가 호출될 때까지 SubmitChanges 이 테이블의 쿼리 결과에 나타나지 않습니다.

적용 대상