Tüm Ürünler
Search
Belge Merkezi

Tablestore:Batch write rows

Son Güncelleme:Oct 02, 2026

Tablestore .NET SDK kullanarak tek bir toplu istekle birden çok tabloya satır ekleyin, güncelleyin ve silin.

Kullanım notları

  • Sunucu herhangi bir işlemde parametre hatası algılarsa özel durum oluşturur ve tüm toplu istek başarısız olur. Hiçbir işlem çalıştırılmaz.

  • Tek bir toplu yazma işlemi en fazla 200 satırı destekler; toplam veri boyutu en fazla 4 MB olabilir.

Ön koşullar

Tablestore istemcisini başlatın

Yöntem

public BatchWriteRowResponse BatchWriteRow(BatchWriteRowRequest request)

Eşzamanlı olmayan yöntem:

public Task<BatchWriteRowResponse> BatchWriteRowAsync(BatchWriteRowRequest request)

BatchWriteRowRequest parametreleri

  • RowChangesGroupByTable (Gerekli)IDictionary<string, RowChanges>: Tablolara göre gruplandırılmış satır işlemleri. Aşağıdaki parametreleri içerir.


    Parametre


    Tür


    Açıklama


    tableName (Gerekli)


    string


    Tablonun adı.


    rowChanges (Gerekli)


    RowChanges


    Yazma, güncelleme ve silme işlemleri.

Kod örnekleri

test_table tablosuna bir satır ekleyin:

try
{
    // Construct the request.
    BatchWriteRowRequest batchWriteRowRequest = new BatchWriteRowRequest();

    // Add RowChanges.
    RowChanges rowChanges = new RowChanges("test_table");
    PrimaryKey primaryKey = new PrimaryKey
    {
        { "id", new ColumnValue("row1") }
    };
    // A condition for the write operation is required. `RowExistenceExpectation.IGNORE` specifies to skip the row existence check.
    Condition condition = new Condition(RowExistenceExpectation.IGNORE);
    rowChanges.AddPut(condition, primaryKey, null);
    batchWriteRowRequest.Add("test_table", rowChanges);

    // Call the BatchWriteRow method to perform the batch write.
    BatchWriteRowResponse batchWriteRowResponse = client.BatchWriteRow(batchWriteRowRequest);

    // Process the response.
    Console.WriteLine($"RequestId: {batchWriteRowResponse.RequestID}");
    if (!batchWriteRowResponse.IsAllSucceed)
    {
        foreach (var item in batchWriteRowResponse.GetFailedRows())
        {
            Console.WriteLine($"Table name: {item.TableName}. Error message: {item.ErrorMessage}");
        }
    }
}
catch (Exception ex)
{
    Console.WriteLine($"Batch write row failed, exception: {ex.Message}");
}

Her işlem türü için örnekler:

  • RowPutChange: Satır yazın.

    PrimaryKey primaryKey = new PrimaryKey
    {
        { "id", new ColumnValue("row1") }
    };
    // A condition for the write operation is required. `RowExistenceExpectation.IGNORE` specifies to skip the row existence check.
    Condition condition = new Condition(RowExistenceExpectation.IGNORE);
    rowChanges.AddPut(condition, primaryKey, null);

    Nitelik sütunlarıyla bir satır yazın:

    PrimaryKey primaryKey = new PrimaryKey
    {
        { "id", new ColumnValue("row1") }
    };
    AttributeColumns columns = new AttributeColumns
    {
        { "col1", new ColumnValue("val1") }
    };
    // A condition for the write operation is required. `RowExistenceExpectation.IGNORE` specifies to skip the row existence check.
    Condition condition = new Condition(RowExistenceExpectation.IGNORE);
    rowChanges.AddPut(condition, primaryKey, columns);
  • RowUpdateChange: Satırı güncelleyin. Nitelik sütunu değerlerini değiştirmeyi, sütun eklemeyi veya bir sütun sürümünü ya da tüm bir sütunu silmeyi destekler.

    PrimaryKey primaryKey = new PrimaryKey
    {
        { "id", new ColumnValue("row1") }
    };
    UpdateOfAttribute updateOfAttribute = new UpdateOfAttribute();
    updateOfAttribute.AddAttributeColumnToPut("col1", new ColumnValue("changed_val1"));
    // A condition for the update operation is required. `RowExistenceExpectation.IGNORE` specifies to skip the row existence check.
    Condition condition = new Condition(RowExistenceExpectation.IGNORE);
    rowChanges.AddUpdate(condition, primaryKey, updateOfAttribute);

    Tek bir güncellemede nitelik sütunları ekleyin ve silin:

    PrimaryKey primaryKey = new PrimaryKey
    {
        { "id", new ColumnValue("row1") }
    };
    UpdateOfAttribute updateOfAttribute = new UpdateOfAttribute();
    // Add an attribute column.
    updateOfAttribute.AddAttributeColumnToPut("col3", new ColumnValue("val3"));
    // Delete an attribute column.
    updateOfAttribute.AddAttributeColumnToDelete("col2");
    // A condition for the update operation is required. `RowExistenceExpectation.IGNORE` specifies to skip the row existence check.
    Condition condition = new Condition(RowExistenceExpectation.IGNORE);
    rowChanges.AddUpdate(condition, primaryKey, updateOfAttribute);
  • RowDeleteChange: Satırı silin.

    PrimaryKey primaryKey = new PrimaryKey
    {
        { "id", new ColumnValue("row1") }
    };
    // A condition for the delete operation is required. `RowExistenceExpectation.IGNORE` specifies to skip the row existence check.
    Condition condition = new Condition(RowExistenceExpectation.IGNORE);
    rowChanges.AddDelete(condition, primaryKey);

İlgili işlemler